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?

arjay07
  • 421
  • 1
  • 6
  • 12

2 Answers2

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
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
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.

Andy Smith
  • 21
  • 1