Question Locked

registry automation

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I want to add a registry key to the Run Once section of a computer every night. I know that manually it could be done via a reg file. How could this be done?

4 replies

by bizzo

If you want to add just a single key, you can use the REG ADD command.

here's some examples from reg add /?

REG ADD \\ABC\HKLM\Software\MyCo
Adds a key HKLM\Software\MyCo on remote machine ABC

REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead
Adds a value (name: Data, type: REG_BINARY, data: fe340ead)

REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail
Adds a value (name: MRU, type: REG_MUTLI_SZ, data: fax\0mail\0\0)

REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d %%systemroot%%
Adds a value (name: Path, type: REG_EXPAND_SZ, data: %systemroot%)
Notice: Use the double percentage ( %% ) inside the expand string

by wesley.chin

Thanks for the reply.

Is there a confirmation prompt when the command is executed in a reg file?

by bizzo

If the registry key is already there it will prompt to see if you want to overwrite it, unless you use the /f switch.

To add a string value, use the REG_SZ datatype.

the last time I needed to use this was to add a system variable. This was the command I used in the batch file.

REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v OPS-PACK /t REG_SZ /d C:\Ops\Pack /f

Which, broken down, adds the key OPS-PACK with string value C:\Ops\Pack and forces overwrite, i.e. no prompt.

This discussion is closed to new replies.