有的时候开发我们需要取得系统管理员权限,可以通过修改注册表实现,研究网上的各种方法,整理得一下脚本实现取得管理员权限
脚本如下
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT*shell unas] @="管理员取得所有权" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT*shell unascommand] @="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F" "IsolatedCommand"="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F" [HKEY_CLASSES_ROOTexefileshell unas2] @="管理员取得所有权" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOTexefileshell unas2command] @="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F" "IsolatedCommand"="cmd.exe /c takeown /f "%1" && icacls "%1" /grant administrators:F" [HKEY_CLASSES_ROOTDirectoryshell unas] @="管理员取得所有权" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOTDirectoryshell unascommand] @="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant administrators:F /t" "IsolatedCommand"="cmd.exe /c takeown /f "%1" /r /d y && icacls "%1" /grant administrators:F /t"