- 帖子
- 9
- 积分
- 20
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2016-9-6
|
在上网发现有以下这段代码让批处理临时获得管理权限可以运行,但是每次都会弹出窗口要求输入管理员账号和密码,现假如我的管理员账户为tpadmin,密码为123456,怎么修改下面代码后不再弹出窗口要求输入管理员账户和密码!谢谢各位大牛!
::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 软媒魔方自动添加批处理文件管理员权限::
::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
CLS
ECHO.
ECHO ================================
ECHO 软媒魔方获取批处理文件管理员权限
ECHO ================================
CLS & COLOR 4F
:init
setlocal DisableDelayedExpansion
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
ECHO.
ECHO ********************************
ECHO 请求 UAC 权限批准……
ECHO ********************************
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
ECHO args = "ELEV " >> "%vbsGetPrivileges%"
ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
ECHO Next >> "%vbsGetPrivileges%"
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
exit /B
:gotPrivileges
setlocal & pushd .
cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1) |
-
1
评分人数
-
|