I am making an installer which will be 100% depending on system variable such as %TEMP% or %Path%, users first double click windows.bat file.
But, How can i setup permanent system variable in Windows XP, Vista, 7, 8 using VBS or BATCH?
I tried with BATCH but in Windows XP, most users do not have setx by default, so i want to avoid using that technique. Is there better way to do that?
C:\Documents and Settings\sun>REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Ses
sion Manager\Environment" /v MyApplicationWillUsetThis /d "C:\WhatEverPathToIncl
udeHereQuestionMark"
The operation completed successfully
C:\Documents and Settings\sun>REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Ses
sion Manager\Environment" /v MyApplicationWillUsetThis /d "C:\WhatEverPathToIncl
udeHereQuestionMark"
Value MyApplicationWillUsetThis exists, overwrite(Y/N)? Y
The operation completed successfully
You can create a REG_SZ value under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment in the registry. The name of the value specifies the name of the environment variable, the value specifies the value of the environment variable.
You can also modify existing values.
In order to modify the registry you can use the RegRead and RegWrite method of the WScript.Shell object. For an example have a look at Manipulating the System Registry.
Edit: You could at first delete the existing value and recreate it afterwards.