Q:

Adding a directory to the system path variable through registry

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?

A:

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

