6

I am going to set a value to windows registry. I want to set variable shit for StupidMS in registry, but the result is wrong. Following is my code.

set stupidMS=shit
echo %stupidMS% 

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v "StupidMS" /t REG_SZ /d ^%stupidMS^%

I think the problem is ^%stupidMS^%, but I quite have no idea how to correct it.

9
  • why do yo escape the %-s ?Try only with %stupidMS% Commented Jul 18, 2013 at 4:53
  • finally I got it. it should "%stupidMS%". I forget "" Commented Jul 18, 2013 at 4:59
  • "%~stupidMS%" is safer. Commented Jul 18, 2013 at 8:08
  • 5
    Perhaps, it would be better to replace the swearing words with "foo" and "bar". Commented Sep 8, 2013 at 8:51
  • 4
    +1 für appropriate variable naming Commented Sep 4, 2014 at 11:29

1 Answer 1

6
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v "StupidMS" /t REG_SZ /d "%stupidMS%"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.