:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params= %*
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
xcopy "%CD%\Package\Contents\" -destination "C:\Program Files (x86)"
pause
=========================
C:\Users\Ryan\Desktop\FL>xcopy "C:\Users\Ryan\Desktop\FL\Package\Contents\" -destination "C:\Program Files (x86)"
Invalid number of parameters
0 File(s) copied
C:\Users\Ryan\Desktop\FL>pause
Press any key to continue . . .
问题在这里
答案1
在您的 xcopy 命令中,您需要删除源路径的最后一个反斜杠。此外,“-destination” 是无效参数。
尝试类似这样的操作:
xcopy /S "%CD%\Package\Contents" "C:\Program Files (x86)"