[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[注册表类] [已解决]如何用命令来修改注册表项所有者

本帖最后由 gm8800 于 2021-4-15 00:08 编辑

比如我"HKEY_LOCAL_MACHINE\SOFTWARE\aaaaa"当前所有者是"SYSTEM",用"Administrator"用户登录没有权限修改,也不能用"regini"命令去修改权限,有没有什么办法修改当前所有者为"Administrator"呀
网上找了,群里也问过了,说可以用"secedit"命令来实现,但是这类的例子好少,自己试过不成功,哪位打下可以指点迷津

powershell v3.0+
  1. $reg = 'HKEY_LOCAL_MACHINE\SOFTWARE\aaaaa';
  2. $user = 'Administrators'; #必须加S
  3. # $user = 'EveryOne'
  4. # $user = "$env:USERNAME"; # 当前登陆用户
  5. iex ([Text.Encoding]::GetEncoding(0x4b0).GetString([convert]::FromBase64String('CQBUAHIAeQAgAHsADQAKAAkACQAkAGsAZQB5AD0AWwBiAHkAdABlAFsAXQBdAFsAYwBoAGEAcgBbAF0AXQAnAF8AKABGADMAdABjAGwAbwBSAGEAXgB2AEQAZgAyAH4AeQArAFoANwBJAHwAegAtAHMAWAA4AEgAWQBUAHEAewBLADkAaQAiAE0AZQAjACUAMQAmADQAWwBkAEAAfQA8AG0AQgAqAEwATwBXADYAPgAnAC4AUwB1AGIAUwB0AHIAaQBuAGcAKAAwACwAIAAzADIAKQA7AA0ACgAJAAkAJABTAGUAYwBTAHQAcgBpAG4AZwA9ACcANwA2ADQAOQAyAGQAMQAxADEANgA3ADQAMwBmADAANAAyADMANAAxADMAYgAxADYAMAA1ADAAYQA1ADMANAA1AE0AZwBCADgAQQBEAFEAQQBkAFEAQgB4AEEARABnAEEAUQBRAEIANgBBAEMAOABBAEwAdwBBADEAQQBFAEkAQQBRAGcAQgB2AEEARABBAEEAVABRAEIAQgBBAEg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QQBBAHkAQQBEAEUAQQBNAGcAQQB4AEEAQQA9AD0AJwB8AEMAbwBuAHYAZQByAHQAVABvAC0AUwBlAGMAdQByAGUAUwB0AHIAaQBuAGcAIAAtAEsAZQB5ACAAJABrAGUAeQAgAC0AZQBhACAAJwBzAGkAbABlAG4AdABsAHkAYwBvAG4AdABpAG4AdQBlACcAOwANAAoACQAJACQAYwByAGUAZAAgAD0AWwBNAGEAbgBhAGcAZQBtAGUAbgB0AC4AQQB1AHQAbwBtAGEAdABpAG8AbgAuAFAAUwBDAHIAZQBkAGUAbgB0AGkAYQBsAF0AOgA6AG4AZQB3ACgAIgAkAGUAbgB2ADoAdQBzAGUAcgBuAGEAbQBlACIALAAkAFMAZQBjAFMAdAByAGkAbgBnACkAOwANAAoACQAJAEkAbgB2AG8AawBlAC0ARQB4AHAAcgBlAHMAcwBpAG8AbgAgACgAJABjAHIAZQBkAC4ARwBlAHQATgBlAHQAdwBvAHIAawBDAHIAZQBkAGUAbgB0AGkAYQBsACgAKQAuAFAAYQBzAHMAdwBvAHIAZAApADsADQAKAAkAfQBjAGEAdABjAGgAIAB7ACAAdwByAGkAdABlAC0AaABvAHMAdAAgACcAC3qPXhmV74sM/wCQ+lEnACAALQBmAG8AcgBlACAAUgBlAGQAOwBQAGEAdQBzAGUAOwBFAHgAaQB0ACAAfQA=')))
  6. pause
复制代码
QQ: 己阵亡
脚本优先 [PowerShell win10]

TOP

本帖最后由 gm8800 于 2021-4-13 22:54 编辑

回复 2# xczxczxcz
谢谢,但是我测试不成功呀,我这是win7系统,不知道为什么我发不了图片(图片大小42kb)
  1. PS C:\Users\Administrator\Desktop> C:\Users\Administrator\Desktop\aaa.ps1
  2. 程序错误,退出
  3. 无法将“Pause”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后重试。
  4. 所在位置 行:6 字符: 47
  5. +     }catch { write-host '程序错误,退出' -fore Red;Pause <<<< ;Exit }
  6.     + CategoryInfo          : ObjectNotFound: (Pause:String) [], CommandNotFoundException
  7.     + FullyQualifiedErrorId : CommandNotFoundException
  8. 无法将“pause”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后重试。
  9. 所在位置 C:\Users\Administrator\Desktop\aaa.ps1:7 字符: 6
  10. + pause <<<<
  11.     + CategoryInfo          : ObjectNotFound: (pause:String) [], CommandNotFoundException
  12.     + FullyQualifiedErrorId : CommandNotFoundException
复制代码
在win10的系统测试也不可以
  1. Set-Acl : 不允许所请求的注册表访问权。
  2. 所在位置 行:3 字符: 1
  3. + Set-Acl -Path "Registry::$reg" -AclObject $acl;
  4. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5.     + CategoryInfo          : PermissionDenied: (HKEY_LOCAL_MACH...eDevicePolicies:String) [Set-Acl], SecurityException
  6.     + FullyQualifiedErrorId : System.Security.SecurityException,Microsoft.PowerShell.Commands.SetAclCommand
  7. 按 Enter 键继续...:
复制代码

TOP

回复 3# gm8800


我在Win7系统里面测试SetACL可以成功修改:
  1. SetACL -on "HKEY_LOCAL_MACHINE\SOFTWARE\aaaaa" -ot reg -actn setowner -ownr "n:Administrators"
复制代码
下载地址:
http://bcn.bathome.net/s/tool/index.html?key=setacl
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 3# gm8800


    改权限需管理员权限运行,这是基本常识,win7需升级PS到3.0以上。
QQ: 己阵亡
脚本优先 [PowerShell win10]

TOP

回复 4# Batcher


    谢谢,这个测试是可以用

TOP

回复 5# xczxczxcz


    就是管理员权限的

TOP

回复 1# gm8800
  1. @echo off
  2. pushd "%temp%"
  3. >sec.inf (
  4.     echo [Version]
  5.     echo signature="$CHICAGO$"
  6.     echo [Registry Keys]
  7.     echo "MACHINE\SOFTWARE\aaaaa", 0, "O:BA"
  8. )
  9. secedit /configure /db sec.sdb /cfg sec.inf /log sec.log
  10. popd
复制代码
我测试了secedit命令也能成功,参考:
http://bbs.bathome.net/thread-13881-1-1.html#pid90982
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

返回列表