这是我的“ unzip.bat”文件。如果我通过单击运行该批处理文件,则可以正常工作。但是,如果我在inno setup的“ [Run]”部分中运行此bat文件,则命令提示符窗口将多次打开,并且不要求我也输入管理员密码。
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>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"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
SET ProgFiles86Root=%ProgramFiles(x86)%
IF NOT "%ProgFiles86Root%"=="" GOTO win64
SET ProgFiles86Root=%ProgramFiles%
:win64
echo on
net session >nul 2>nul&if errorlevel 1 Batch_Admin "%~0" %*
"C:\Program Files\7-Zip\7z.exe" e "%ProgFiles86Root%\folder1\folder2\filename.zip" -y -o"%ProgFiles86Root%\folder1\folder2"
pause
echo Done!
exit