我有一个简单的 bat 脚本,它将文件从一个已知目录复制到用户指定的目录。如何将路径(它可能包含空格)传递给脚本并与 xcopy 命令一起使用它?
在我的代码中,我有以下内容
:READ_PWA_PATH
if "%1" == "" (
rem Set default path
set PWA_PATH="C:\Program Files\PWA"
rem
echo You have not specified your PWA url.
echo Default will be assumed: C:\Program Files\PWA.
choice /C:YN /M:"Do you wish to continue [Y] or cancel the script [N]?"
IF ERRORLEVEL ==2 GOTO CANCEL
IF ERRORLEVEL ==1 GOTO READ_WSS_SERVER_EXTENSIONS_PATH
GOTO END
) else (
set PWA_PATH=%1
)
如果我简单地调用脚本,我会得到以下错误:
C:\Projects\Setup>install.cmd "C:\program files (x86)"
-----------------
SETUP SCRIPT
-----------------
files was unexpected at this time.
C:\Projects\Setup>