1
Just1n 2014-05-02 11:37:26 +08:00
是随时还是?
我前段时间有一个每次开机都要管理员权限运行一个批处理文件的需求,用的是windows计划任务。 |
3
scusjs 2014-05-02 13:38:18 +08:00
@echo off
%1 %2 ver|find "5.">nul&&goto :st mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :st","","runas",1)(window.close)&goto :eof :st copy "%~0" "%windir%\system32\" 这是以前不知道哪里复制的,把自己的命令加在后面就可以了 |
4
vibbow 2014-05-02 14:07:39 +08:00
@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" :-------------------------------------- <YOUR BATCH SCRIPT HERE> |