[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]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

第一行加上下面一句,保存为bat
  1. @cd /d %~dp0 & powershell -command "Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" & pause & exit/b
复制代码
回复 25# hentai87
1

评分人数

TOP

回复 24# newswan


    可以了,
有办法bat实现吗

TOP

回复 23# hentai87

那是不完整的, 对比你已有代码, 添加一句
  1. $path = "HKLM:\SECURITY\Policy\Accounts\S-1-1-0\Privilgs"
复制代码
或者
  1. Set-ItemProperty -Path "HKLM:\SECURITY\Policy\Accounts\S-1-1-0\Privilgs" -Name "(Default)" -Type None -Value $a
复制代码
1

评分人数

TOP

回复 22# newswan


    Set-ItemProperty : 无法将参数绑定到参数“Path”,因为该参数是空值。
所在位置 行:1 字符: 24
+ set-ItemProperty -Path $path -Name "(Default)" -Type None -Value $a
+                        ~~~~~
    + CategoryInfo          : InvalidData: ( [Set-ItemProperty],ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetItemProp
   ertyCommand

TOP

本帖最后由 newswan 于 2023-4-21 01:02 编辑

回复 21# hentai87


十进制 17 转成了十六进制 11
  1. $str = "01,00,00,00,00,00,00,00,17,00,00,00,00,00,00,00,03,00,00,00"
  2. [byte[]]$a = $str -replace "(?=\d\d)","0x" -split ","
  3. set-ItemProperty -Path $path -Name "(Default)" -Type None -Value $a
复制代码

TOP

回复 20# newswan


[byte[]]$a = @("01","00","00","00","00","00","00","00","17","00","00","00","00","00","00","00","03","00","00","00")
Set-ItemProperty -Path "HKLM:\SECURITY\Policy\Accounts\S-1-1-0\Privilgs" -Name "(Default)" -Type None -Value $a
还是不对,明明是17,却变成了11
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,11,00,00,00,00,00,00,00,03,00,00,00
应该是17
@=hex(0):01,00,00,00,00,00,00,00,17,00,00,00,00,00,00,00,03,00,00,00

TOP

回复 19# hentai87
  1. [byte[]]$a = @("00","03","15")
复制代码
改这里啊

TOP

回复 18# newswan


Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SECURITY\Policy\Accounts\S-1-1-0\Privilgs]
@=hex(0):00,03,0f

执行后,数据是这个

TOP

本帖最后由 newswan 于 2023-4-20 03:11 编辑

测试正确的啊
https://imgse.com/i/p9kE4R1
  1. [byte[]]$a = @("00","03","15")
  2. Set-ItemProperty -Path "HKLM:\SECURITY\Policy\Accounts\S-1-1-0\Privilgs" -Name "(Default)" -Type None -Value $a
复制代码
用 set-ItemProperty 试试

TOP

回复 16# newswan


    New-ItemProperty后的数据不对

TOP

本帖最后由 newswan 于 2023-4-18 21:19 编辑

回复 15# hentai87


Remove-ItemProperty 是删除 value ,错误可以忽略
New-ItemProperty 不出错就行

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

本帖最后由 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

回复 8# newswan


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

TOP

返回列表