日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
批處理set命令
批處理中的set命令用于設(shè)置環(huán)境變量。

批處理BAT腳本是Windows操作系統(tǒng)中一種非常實(shí)用的腳本語言,它可以幫助我們自動(dòng)化完成一些重復(fù)性的工作,在批處理腳本中,set命令是一個(gè)非常重要的命令,它可以用來設(shè)置或顯示環(huán)境變量,本文將對(duì)set命令的使用進(jìn)行詳細(xì)的介紹。

set命令的基本用法

1、設(shè)置環(huán)境變量

使用set命令可以設(shè)置環(huán)境變量,語法如下:

set 變量名=變量值

我們可以設(shè)置一個(gè)名為PATH的環(huán)境變量,用于存儲(chǔ)程序的搜索路徑:

set PATH=C:Windows;C:Program FilesJava;C:Program FilesPython

2、顯示環(huán)境變量

使用set命令可以顯示當(dāng)前已經(jīng)設(shè)置的所有環(huán)境變量,語法如下:

set

我們可以查看當(dāng)前已經(jīng)設(shè)置的所有環(huán)境變量:

set

set命令的常用選項(xiàng)

1、/a:追加環(huán)境變量,而不是覆蓋原有的值,如果環(huán)境變量已經(jīng)存在,則在其值的后面追加新的值;如果環(huán)境變量不存在,則直接設(shè)置新的值。

我們可以追加一個(gè)名為JAVA_HOME的環(huán)境變量:

set JAVA_HOME=C:Program FilesJava /a

2、/p:提示用戶輸入要設(shè)置的值,這對(duì)于需要用戶輸入的環(huán)境變量非常有用。

我們可以提示用戶輸入一個(gè)名為USERNAME的環(huán)境變量:

set /p USERNAME=請(qǐng)輸入用戶名:

3、/x:刪除指定的環(huán)境變量,如果環(huán)境變量不存在,則不執(zhí)行任何操作。

我們可以刪除一個(gè)名為TEST的環(huán)境變量:

set TEST= /x

set命令的注意事項(xiàng)

1、set命令設(shè)置的環(huán)境變量?jī)H對(duì)當(dāng)前的批處理腳本有效,當(dāng)腳本執(zhí)行完畢后,設(shè)置的環(huán)境變量會(huì)自動(dòng)失效,如果需要永久設(shè)置環(huán)境變量,可以將set命令添加到系統(tǒng)的環(huán)境變量配置文件中(如Windows系統(tǒng)中的system32driversetchosts文件)。

2、set命令設(shè)置的環(huán)境變量是以字符串的形式存儲(chǔ)的,即使我們需要設(shè)置的是數(shù)字或其他類型的值,也需要將其轉(zhuǎn)換為字符串,我們可以將一個(gè)數(shù)字轉(zhuǎn)換為字符串并設(shè)置為環(huán)境變量:

set NUMBER=12345 /a
echo %NUMBER% > temp.txt && type temp.txt | findstr /r "^[0-9]*$" > nul && set /p NUMBER=> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMBER% >> num.txt && for /f "delims=" %%i in (num.txt) do set NUMBER=%%i && del num.txt && echo %NUMBER%:%NUMTALBREAK>12345:12345>> num.txt && for /f "delims=" %i in (num.txt) do set NUMBER=!i! & goto endnum & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch & endlocal & goto endbatch &endnum:&for /f "tokens=*" %j in ('dir /b C:') do if not "%~j" == "num.txt" if not "%~j" == "nul" if not "%~j" == "temp.txt" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0" if not "%~j" == "%~nx0" if not "%~j" == "%~dp0ifnot "%~j" == "%~nx0ifnot "%~j" == "%~dp0ifnot "%~j" == apendnumifnot ""==12345goto startnum&goto startnum&goto start

當(dāng)前標(biāo)題:批處理set命令
分享URL:http://www.5511xx.com/article/dpghopj.html