windows添加“以管理员身份运行”

方法:

  1. 新建一个txt文件,命名为"admin.txt",记得打开“显示后缀名”,要求看到.txt并可修改之。

  2. 将下列代码粘贴进去。

    Windows Registry Editor Version 5.00
    [HKEY_CLASSES_ROOT\*\shell\runas]@="管理员取得所有权""NoWorkingDirectory"=""
    [HKEY_CLASSES_ROOT\*\shell\runas\command]@="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_ROOT\exefile\shell\runas2]@="管理员取得所有权""NoWorkingDirectory"=""
    [HKEY_CLASSES_ROOT\exefile\shell\runas2\command]@="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_ROOT\Directory\shell\runas]@="管理员取得所有权""NoWorkingDirectory"=""
    [HKEY_CLASSES_ROOT\Directory\shell\runas\command]@="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"
    
  3. 保存为"admin.reg",准备写入注册表。

  4. 双击之,将其写入注册表即可。

效果:再次右键点击某文件的时候,就会发现菜单栏里多了一项“管理员取得所有权”,我们的目的也就达到了。

后记:以前每次装机后,都会百度这对代码,现在还是记录一下吧,不然也麻烦。

猜你喜欢

转载自www.cnblogs.com/young233/p/11946755.html