2017-04-01 58 views
0

我想要一個可以查看'set是否存在的代碼。BATCH「設置」命令問題

例子:

@echo of 
// Now the thing i want: 
if not exist "%user%" (
goto :Register 
) 
:login 
call Functions\user.bat 
echo Hello %user%! 
pause 

:register 
echo Register.. 
pause 

現在怎麼讓我的批處理文件,以檢查是否存在與否%用戶%。 %用戶%不是我腳本btw中的文件夾。

+1

這個問題對我來說還不清楚。批次中沒有任何設置命令。如果您想知道是否設置了var,請使用'if defined varname'參見[ss64.com/nt/Set](http://ss64.com/nt/set.html)和[ss64.com/nt/if ](http://ss64.com/nt/if.html) – LotPings

回答

0
if not exist "%user%" 

測試文件或目錄是否存在此名稱的變量user

if not defined user 

測試變量是否已經user在環境中設置的內容。