我正在尝试运行一个脚本,有人告诉我这是一个批处理脚本;这是第一个块,用于语法参考...
[HKEY_CLASSES_ROOT\*\shell\TakeOwnership]
@="Take Ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
"Position"="middle"
...
但是,将内容保存到.bat
容器中并通过提升cmd
或运行ps
似乎不起作用,它似乎也不是.reg
文件。应该如何运行?
答案1
使用以下代码并保存为
file.bat
或file.cmd
将此行添加为 bat 在寄存器中添加键/值本身的命令
;@(cls & %__APPDIR__%reg.exe import "%~f0" 2>nul >nul & goto :EOF)
- 以管理员身份运行
Windows Registry Editor Version 5.00
;@(cls & %__APPDIR__%reg.exe import "%~f0" 2>nul >nul & goto :EOF)
[HKEY_CLASSES_ROOT\*\shell\TakeOwnership]
@="cmd.exe /c takeown /f \"%1\"
"HasLUAShield"=""
"NoWorkingDirectory"=""
"Position"="middle"
- 或者你可以使用这个博客上描述的代码轻松取得所有权并授予完全控制权限,赢得所有权从raymond.cc/blog:...
Windows Registry Editor Version 5.00
;@(cls & %__APPDIR__%reg.exe import "%~f0" 2>nul >nul & goto :EOF)
[-HKEY_CLASSES_ROOT\*\shell\runas]
[HKEY_CLASSES_ROOT\*\shell\runas]
@="Take Ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F /c /l"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F /c /l"
[-HKEY_CLASSES_ROOT\Directory\shell\runas]
[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Take Ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t /c /l /q"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t /c /l /q"
[-HKEY_CLASSES_ROOT\dllfile\shell\runas]
[HKEY_CLASSES_ROOT\dllfile\shell\runas]
@="Take Ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\dllfile\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F /c /l"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F /c /l"
[-HKEY_CLASSES_ROOT\Drive\shell\runas]
[HKEY_CLASSES_ROOT\Drive\shell\runas]
@="Take Ownership"
"HasLUAShield"=""
"NoWorkingDirectory"=""
"Position"="middle"
[HKEY_CLASSES_ROOT\Drive\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t /c /l /q"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t /c /l /q"
[-HKEY_CLASSES_ROOT\exefile\shell\runas]
[HKEY_CLASSES_ROOT\exefile\shell\runas]
"HasLUAShield"=""
[HKEY_CLASSES_ROOT\exefile\shell\runas\command]
@="\"%1\" %*"
"IsolatedCommand"="\"%1\" %*"