
我在批次檔程式碼中編寫了以下程式碼
if not exist "C:\Windows\Temp\web.config.hints.cancer.gov" (
echo Error: "%TMP%\web.config.hints.cancer.gov" does not exist! )
pause
exit
然而,它並沒有相應地運行。我收到以下訊息
C:\Users\dod\Desktop>if not exist "C:\Windows\Temp\web.config.hints.cancer.gov"
(echo Error: "C:\Users\dod\AppData\Local\Temp\web.config.hints.cancer.gov" does
not exist! )
Error: "C:\Users\dod\AppData\Local\Temp\web.config.hints.cancer.gov" does not ex
ist!
C:\Users\dod\Desktop>pause
Press any key to continue . . .
答案1
%TMP%
%TEMP%
兩者都指向,而C:\Users\username\AppData\Local\Temp
不是指向C:\Windows\Temp
。您需要編寫完整路徑或手動將其放入變數中,如下所示:
SET folder="C:\Windows\Temp"
...your code...
echo Error: %folder%\web.config.hints.cancer.gov does not exist!