Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This is a follow-up to Set Permanent Environmental Variable in Windows XP.

I want to change System variables in XP through running a bat file. But when I run it I get the error "Too many command-line parameters"

This is the code:

set KEY="HKLM\SYSTEM\CurrentControlSet\Control\Sessions Manager\Environment"
set PATHxx=%Path%
reg add %KEY% /v Pathx /t REG_EXPAND_SZ 5 /d %PATHxx%

How can I fix this?

share|improve this question

1 Answer 1

Should the 5 be in there?

You've probably got spaces in your path

Try this:

set KEY="HKLM\SYSTEM\CurrentControlSet\Control\Sessions Manager\Environment"
set PATHxx=%Path%
reg add %KEY% /v Pathx /t REG_EXPAND_SZ /d "%PATHxx%"

You also might want to include:

/f - Force overwriting the existing registry entry without prompt

share|improve this answer
    
but still i get the error Too many command-line parameters –  shyameniw Apr 27 '10 at 11:32
    
I've updated my answer... –  Shevek Apr 27 '10 at 12:00
    
I've updated again! –  Shevek Apr 27 '10 at 12:09
    
hello, now it don't get the error, and it says The operation completed successfully But the environment variable Pathx is not created in Computer--> properties --> Advanced -->Environment Variables --> System Variables –  shyameniw Apr 30 '10 at 4:23
    
@shyameniw - I think it's a permissions thing specific to that part of the registry. My testing did not allow me to create the key in that location but did elsewhere in the registry. Try a test to HKLM\SOFTWARE\SuperUser instead and check in Regedit to see if that created. –  Shevek Apr 30 '10 at 5:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.