0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AHKをスタートアップに登録する

Last updated at Posted at 2021-05-01

AHKをコンパイルして作成したexeファイルをPC起動時に自動的に起動できるようにできないか調べてみたら簡単に見つかった

ここから行き着くフォルダパスはこれ
C:\Users\ユーザー名\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

ここにAHKのショートカットを放り込めばいいだけ

スタートアップメニューのフォルダを開くコード

各ユーザにユーザー名をいちいち入力してもらうのも面倒なのでvbsコードにまとめた
とりあえずこれを実行すればスタートアップフォルダが開く

さすがにこのフォルダにショートカットをコピーして持ってくるとかはいささか乱暴なのでパス

GetUserName.vbs
'ユーザー名を取得する
Dim x
Set x = WScript.CreateObject("WScript.Network")
'WScript.Echo "ユーザ名:" & x.UserName		'ユーザー名をポップアップ表示


'パスをセット
Dim Path
Path = "C:\Users\" & x.UserName & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

Dim objFolder

'WshShellのオブジェクトを作成する
Set objFolder = WScript.CreateObject ("Shell.Application")

'Exploreメソッドの引数にパスを指定する
objFolder.Explore Path

Set objFolder = Nothing
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?