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

[注册表类] 批处理命令reg add如何添加reg_none类型的数据?

本帖最后由 hentai87 于 2023-4-18 18:42 编辑

这是是原本导出的正确数据
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\S-1-1-0\Privilgs]
@=hex(0):01,00,00,00,00,00,00,00,17,00,00,00,00,00,00,00,03,00,00,00
  1. reg add "HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\S-1-1-0\Privilgs" /ve /t reg_none /d "01,00,00,00,00,00,00,00,17,00,00,00,00,00,00,00,03,00,00,00" /f
复制代码
这样导入的数据是错误的,无法直接用导出的数据直接reg add
reg add之后,数据不对,导出数据变了,错误的
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\S-1-1-0\Privilgs]
@=hex(0):68,00,65,00,78,00,28,00,30,00,29,00,3a,00,30,00,31,00,2c,00,30,00,30,\
  00,2c,00,30,00,30,00,2c,00,30,00,30,00,2c,00,30,00,30,00,2c,00,30,00,30,00,\
  2c,00,30,00,30,00,2c,00,30,00,30,00,2c,00,31,00,37,00,2c,00,30,00,30,00,2c,\
  00,30,00,30,00,2c,00,30,00,30,00,2c,00,30,00,30,00,2c,00,30,00,30,00,2c,00,\
  30,00,30,00,2c,00,30,00,30,00,2c,00,30,00,33,00,2c,00,30,00,30,00,2c,00,30,\
  00,30,00,2c,00,30,00,30,00,00,00

  1. reg add "HKLM\SECURITY\Policy\Accounts\S-1-1-0\Privilgs" /f /ve /t REG_NONE /d 01,00,00,00,00,00,00,00,17,00,00,00,00,00,00,00,03,00,00,00
复制代码

TOP

回复 2# chishingchan


    导入之后数据不对,逗号,空格,不加符号,都试过了,都不行

TOP

应该是 REG_BINARY

TOP

回复 4# newswan


    换成REG_BINARY,虽然数据对了,但是注册表设置没能生效,类型必须是reg_none

TOP

回复 1# hentai87
  1. reg add "" /v @ /t REG_SZ /d hex(0):01,00,00,00,00,00,00,00,17,00,00,00,00,00,00,00,03,00,00,00 /f
复制代码

TOP

回复 6# yakeyun


    错误: 无效项名。
键入 "REG ADD /?" 了解用法信息。

TOP

本帖最后由 newswan 于 2023-4-18 16:58 编辑

回复 5# hentai87

reg add 不行的话,用 reg IMPORT *.reg

powershell 可以
  1. [byte[]]$a = @("00","03","15")
  2. New-ItemProperty -Path "HKLM:\Software\zzz" -Name "aaa" -Type None -Value $a
复制代码

TOP

本帖最后由 yakeyun 于 2023-4-18 13:12 编辑

回复 7# hentai87

路径漏了,再加个提权看看,普通权限和管理员权限各执行一次:
  1. @echo off
  2. reg add "HKLM\SECURITY\Policy\Accounts\S-1-1-0\Privilgs" /v @ /t REG_SZ /d hex(0):01,00,00,00,00,00,00,00,17,00,00,00,00,00,00,00,03,00,00,00 /f
  3. %1 %2
  4. ver|find "5.">nul&&goto :Admin
  5. mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :Admin","","runas",1)(window.close)&goto :eof
  6. :Admin
  7. reg add "HKLM\SECURITY\Policy\Accounts\S-1-1-0\Privilgs" /v @ /t REG_SZ /d hex(0):01,00,00,00,00,00,00,00,17,00,00,00,00,00,00,00,03,00,00,00 /f
  8. exit
复制代码
从测试来看,应该是要超级权限才行。

TOP

回复 9# yakeyun


    类型必须是reg_none

TOP

回复 8# newswan


  [byte[]]$a = @("00","03","15")
New-ItemProperty -Path "HKLM:\SECURITY\Policy\Accounts\S-1-1-0\Privilgs" -Name "@" -Type None -Value $a

New-ItemProperty : 该属性已存在。
所在位置 行:1 字符: 1
+ New-ItemProperty -Path "HKLM:\SECURITY\Policy\Accounts\S-1-1-0\Privil ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceExists: (HKEY_LOCAL_MACH...-1-1-0\Privilgs:String) [New-ItemProperty], IOExcepti
   on
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.NewItemPropertyCommand

TOP

回复 9# yakeyun


    不用提权,我已经解锁了权限

TOP

回复 8# newswan


regedit.exe/s可以导入reg文件成功修改,但是我想不用额外文件,直接命令实现

TOP

本帖最后由 newswan 于 2023-4-18 21:18 编辑
  1. [byte[]]$a = @("00","03","15")
  2. Remove-ItemProperty -Path "HKLM:\SECURITY\Policy\Accounts\S-1-1-0\Privilgs" -Name "(Default)"
  3. New-ItemProperty -Path "HKLM:\SECURITY\Policy\Accounts\S-1-1-0\Privilgs" -Name "(Default)" -Type None -Value $a
复制代码

TOP

回复 14# newswan

Remove-ItemProperty : 路径 HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\S-1-1-0\Privilgs 处不存在属性 (Default)。
所在位置 行:1 字符: 1
+ Remove-ItemProperty -Path "HKLM:\SECURITY\Policy\Accounts\S-1-1-0\Pri ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: ((Default):String) [Remove-ItemProperty],PSArgumentException
    + FullyQualifiedErrorId : System.Management.Automation.PSArgumentException,Microsoft.PowerShell.Commands.RemoveIte
   mPropertyCommand

TOP

返回列表