简体   繁体   中英

Adding a new registry file through batch commands

So I've been trying to add a new registry key and it's been working fine, noting the fact that this addition is not going to harm my computer it's just for me to understand a few concepts. The problem that's been happening is as follows, when I run my batch file, it's displaying the following message in cmd:

 off REG ADD HKLM\Software\Hello - 24919 /v Test /t REG_BINARY /d fe340ead

the "off" in bold is a little weird, I'm not sure what happened for it to appear and not add the key, like I said I'm using batch commands and basically writing to another batch file through my initial batch file and this is the code I used:

@echo off
set new=new2.bat
echo @echo off REG ADD HKLM\Software\Hello - %random% /v Test /t REG_BINARY /d fe340ead    >>%new%

Help is appreciated please! and thank you!

PS: I've referred to the following question ( adding a random key to the registry through a batch file ) , and did exactly the same, it worked once but then I don't know what happened for the above to show and not add the key.

@echo off
set new=new2.bat
(
    echo @echo off 
    echo ^>nul REG ADD "HKLM\Software\Hello - %random%" /v Test /t REG_BINARY /d fe340ead
) > %new%

You need to place the @echo off and the REG ADD in separate lines

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM