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?

Windowsで%USERPROFILE%みたいな独自ショートカットを作る方法

0
Posted at

はじめに

よく使うフォルダのパスを、%USERPROFILE%みたいに短く呼び出せたら便利ですよね。
今回はWindowsのsetxコマンドで、自分だけの環境変数を作る方法を紹介します。

問題

C:\Users\007476\Pictures\Screenshotsのような長いパスを、コマンドやエクスプローラーで毎回打つのが面倒でした。

解決方法

setxコマンドを使うと、独自の環境変数を作成できます。

setx MYSHOT "C:\Users\007476\Pictures\Screenshots"

これでMYSHOTという環境変数が作成されます。

ただしsetxはレジストリを更新するだけなので、今開いているターミナルにはすぐには反映されません。ターミナルを再起動すると使えるようになります。

  • cmdの場合:%MYSHOT%
  • PowerShellの場合:$env:MYSHOT

すぐに試したい場合は、今開いているPowerShellでこちらを実行すればOKです。

$env:MYSHOT = "C:\Users\007476\Pictures\Screenshots"

おわりに

setxを使えば、長いパスを短い名前で呼び出せるようになります。よく使うフォルダがある人はぜひ試してみてください。

JISOUのメンバー募集中!

プログラミングコーチングJISOUでは、新たなメンバーを募集しています。
日本一のアウトプットコミュニティでキャリアアップしませんか?
興味のある方は、ぜひホームページをのぞいてみてください!
▼▼▼
https://projisou.jp

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?