我刚刚制作了一个带有快速批处理文件(.exe
)命令的.bat
文件......
我想知道:
如何在打开.exe
文件时强行请求提升权限? (无需右键单击)
答案 0 :(得分:1)
对于这个,您必须检查批处理文件是否提升,然后运行VBS文件:
@echo off
SetLocal EnableDelayedExpansion
rem Get the file itself name
set filename=%0
rem Check if batch file is elevated or not:
reg query "HKU\S-1-5-19" >nul 2>&1
if %errorlevel%==1 (
echo.Set UAC = CreateObject^("Shell.Application"^) > "elevated.vbs"
echo.UAC.ShellExecute "!filename!", "", "", "runas", 1 >> "elevated.vbs"
"elevated.vbs"
goto :eof
)
if %errorlevel%==0 goto elevated
:elevated
rem Now, run the exe file (like use 'start' command, or execute it as a command:
yourExecuteableFileInHere.exe
但上面的代码仍有一些错误。您可能想要修复它(或者可能不是?)