结束任务管理器

Ending task manager

在cmd中,如果我输入代码

taskkill /f /im explorer.ex

它结束了资源管理器。但是如果我输入

taskkill /f /im taskmgr.exe

它说访问被拒绝,唯一的方法是以管理员身份打开cmd。有没有办法不用以管理员身份打开,或者有没有办法在您打开批处理脚本时自动以管理员身份打开? 提前致谢。

我一直在使用此模板执行管理任务。希望对你有帮助。

:: Verify we don't have administrator privileges
net file >nul 2>&1
if "%errorlevel%" equ "0" goto :admin

:: Execute VB script to execute the script with elevated privileges
(
    echo Set UAC = CreateObject^("Shell.Application"^)
    echo UAC.ShellExecute "%~dpf0", "", "%~dp0", "runas", 1
) > "%temp%\get-privileges.vbs"

"%temp%\get-privileges.vbs"
exit /b

:admin
::Administrator work here!!