# Runonce with batch



## Solaris17 (Nov 5, 2014)

Hey guys need some quick help here. i need to add a reg key to a batch file I will be making but I cant get it to work right. its a run once key. I can manually make the key no problem but when trying to add it via batch well im not super versed with adding registry keys with batch so im having a hard time understanding the syntax needed. Here is the original key as iv dumped from the registry after I made it. I need this key to be put into registry via batch (add reg) can anyone help?


```
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]
"Message"="MSG * THIS IS THE MESSAGE"
```


----------



## Solaris17 (Nov 5, 2014)

sl;ight bump


----------



## W1zzard (Nov 5, 2014)

regedit has a command line option to import reg dumps
http://support.microsoft.com/kb/82821

you might need admin privileges to write to that key


----------



## Solaris17 (Nov 5, 2014)

running as admin wont be an issue but my biggest issue is that the batch may not always be run with the .reg present.


----------



## W1zzard (Nov 5, 2014)

What do you mean ? You could create the reg file from the batch file, writing to tmp


----------



## Solaris17 (Nov 5, 2014)

W1zzard said:


> What do you mean ? You could create the reg file from the batch file, writing to tmp



I suppose I can try this and report my success. I only mentioned add reg because I have the batch doing other things and it seemed simple to just include 1 or 2 lines to write the entry.


----------



## Solaris17 (Nov 5, 2014)

I managed to do it via 1 line in batch the code is as follows. for a standard message via runonce


```
Reg Add HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v Message /d "MSG * YOUR MESSAGE" /f
```

obviously change HKLM to HKCU for the user of your choice instead.


----------

