I am trying to add a environment variable (System) in my batch file. The below command says ERROR: Invalid syntax. Can some one help. For me it looks good.
r
SetX.exe is probably the easiest way to do this in a batch file. It also feels a bit safer than directly writing to the Registry just to add an Environment Variable.
SetX syntax page
For your example the variable's:
The SetX command line would be:
SetX.exe ToDelete "192.168.00.00" /m
Note that this CMD was executed as an administrator. Depending on your systems setup SetX may not run under your users permissions.
Another thing to remember about SetX is that the update does not happen to the Environment in the current CMD window. you have to either also run a Set for the variable (temporary) or close and reopen CMD to see the update.
In most cases (in scripts) it means running both commands. Note below this is a standard CMD session (has been closed and reopened).