2

I am trying to add a directory to the PATH variable in windows. This is what I am entering the command line. (Or a batch file)

@echo off
set value=%path%;%ProgramFiles%\AtomScript\
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Sessions Manager\Environment" /v Path /t REG_EXPAND_SZ /d %value% /f

And it comes up with this message

ERROR: Invalid syntax.
Type "REG ADD /?" for usage.

What am I doing wrong?

2 Answers 2

4

You probably have to quote %value% (with double-quotes) because its expansion has embedded blanks for C:\Program Files, etc.

That would be

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Sessions Manager\Environment" /v Path /t REG_EXPAND_SZ /d "%value%" /f

You can see what the actual expansions are by turning echo on in your script:

@echo on
Sign up to request clarification or add additional context in comments.

3 Comments

It spells Session Manager (singular Session) in my Window 2016 Data Center.
agreed, but that wouldn't answer OP's question about a syntax error.
It is Session Manager (singular Session) in Windows 10.
0

Maybe you solved it already, but as far as I can see you also might have a misspelling in "...\Sessions Manager...". At least on my system it's "Session" without the extra s.

1 Comment

The length and non-specificity of your answer indicates that it should be a comment instead.

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.