2
當我的備份腳本中的FOR循環使用雙引號輸入參數(「Default User」)時,我在xcopy命令行出現「無效的參數數量」錯誤,除非我使用一對額外的雙引號括起來,引號。其他命令工作正常,沒有額外的引號。有人可以解釋爲什麼xcopy以這種方式行事,並且如果有避免額外引號的解決方法?謝謝。爲什麼xcopy需要多個引號?
@echo off
setlocal
set drive=O:\Backups\test
set backupcmd=xcopy /s /c /d /e /i /r /y
if exist "c:\users" goto startvis7
if exist "c:\documents and settings\" goto startxp
:startxp
for %%a in ("Default User" Owner) do (
if exist "c:\documents and settings\%%a" (
echo ### Backing up desktop for %%a...
%backupcmd% ""c:\documents and settings\%%a\desktop"" ""%drive%\%%a\desktop""
) else (echo ### Account %%a not found.)
)
goto eof
:startvis7
for %%a in ("Default User" Owner) do (
if exist "c:\users\%%a" (
echo ### Backing up desktop for %%a...
%backupcmd% ""c:\users\%%a\desktop"" ""%drive%\%%a\desktop""
) else (echo ### Account %%a not found.)
)
:eof
echo Backup Complete!
@pause
endlocal