Reputation: 4665
I have @echo off
at the beginning, and exit
at the end.. The bat adds entry to registry. However, if the registry exists, it gives this message. How to avoid that ? Thanks.
Upvotes: 0
Views: 181
Reputation: 14305
echo y|reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "appdataid" /d %appdata%\data.vbs
if you want to overwrite the existing entry
echo n|reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "appdataid" /d %appdata%\data.vbs
if you don't
Also, if for some reason you don't want to (or can't) pipe the echo output, you can force reg add to overwrite the value with the /f
flag, like reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "appdataid" /d %appdata%\data.vbs /f
Upvotes: 2