set - setx - 環境変数の操作

set

代入・再代入

 set mesg=hello
 echo %mesg%
   => "hello"
 
 set mesg=%mesg%, world
 echo %mesg%
   => "hello, world"

数値演算

 set num1=10
 set /a num2=%num1%*2
 echo %num2%
   => "20"

文字列置換

 set mesg=foo
 set mesg=%mesg:oo=xx%
 echo %mesg%
   => "fxx"

部分文字列の取り出し

 set mesg=foo
 set mesg=%mesg:~0,2%
 echo %mesg%
   => "fo"

参考

http://www.geocities.co.jp/SiliconValley-SanJose/1227/variable.html

setx

ユーザ環境変数の設定

 setx PATH "%PATH%;C:\App\bin"

システム環境変数の設定

 setx /m PATH "%PATH%;C:\App\bin"

参考


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