• 追加された行はこの色です。
  • 削除された行はこの色です。
* set - setx - 環境変数の操作 [#ee91d735]

** set [#da154531]

*** 代入・再代入 [#t37346db]
 set mesg=hello
 echo %mesg%
   => "hello"
 
 set mesg=%mesg%, world
 echo %mesg%
   => "hello, world"

*** 数値演算 [#t093ec53]
 set num1=10
 set /a num2=%num1%*2
 echo %num2%
   => "20"

*** 文字列置換 [#x6cb54dd]
 set mesg=foo
 set mesg=%mesg:oo=xx%
 echo %mesg%
   => "fxx"

*** 部分文字列の取り出し [#v73d4402]
 set mesg=foo
 set mesg=%mesg:~0,2%
 echo %mesg%
   => "fo"

*** 参考 [#odd1cf02]
http://www.geocities.co.jp/SiliconValley-SanJose/1227/variable.html

** setx [#f42b8254]
*** ユーザ環境変数の設定 [#re218fb7]
 setx PATH "%PATH%;C:\App\bin"

*** システム環境変数の設定 [#d7933129]
 setx /m PATH "%PATH%;C:\App\bin"

*** 環境変数のクリア [#hf6727cc]
 setx FOO ""
環境変数FOOの値が""になるが、FOOキーは残る。

*** 環境変数の削除 [#d3bc75a6]
 reg delete HKCU\Environment /v FOO
レジストリからエントリーを削除することによって、環境変数FOOそのものが削除される。

*** 参考 [#lf4f8ac3]
- http://www.atmarkit.co.jp/fwin2k/win2ktips/1003setx/setx.html
- http://www.atmarkit.co.jp/fwin2k/win2ktips/1006setxf/setxf.html
- http://stackoverflow.com/questions/13222724/command-line-to-remove-an-environment-variable-from-the-os-level-configuration


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS