|
Answer» Dear All,
How can I add new user environment variable by DOS command???
is it possible?? PLEASE advise
Thanks in advance.
see attach image:
[year+ old attachment deleted by admin]Why do you need to CREATE a permanent variable?
There's probably a registry hack to do it, but your answer to the question will help decide which way to go.You can do this with the SETX command. It is part of the Windows Support tools. If you don't have the disc for the support tools I believe it can be downloaded.Thanks Squashman. It is part of Windows 7 now.
This is from the help:
Code: [Select]NOTE: 1) SETX writes variables to the master environment in the registry.
2) On a local system, variables created or modified by this tool will be AVAILABLE in future command windows but not in the current CMD.exe command window.
3) On a remote system, variables created or modified by this tool will be available at the next logon session.
4) The valid Registry Key data types are REG_DWORD, REG_EXPAND_SZ, REG_SZ, REG_MULTI_SZ.
5) Supported hives: HKEY_LOCAL_MACHINE (HKLM), HKEY_CURRENT_USER (HKCU).
6) Delimiters are case sensitive.
7) REG_DWORD values are extracted from the registry in decimal format.
Examples: SETX MACHINE COMPAQ SETX MACHINE "COMPAQ COMPUTER" /M SETX MYPATH "%PATH%" SETX MYPATH ~PATH~ SETX /S system /U user /P password MACHINE COMPAQ SETX /S system /U user /P password MYPATH ^%PATH^% SETX TZONE /K HKEY_LOCAL_MACHINE\System\CurrentControlSet\ Control\TimeZoneInformation\StandardName SETX BUILD /K "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\CurrentBuildNumber" /M SETX /S system /U user /P password TZONE /K HKEY_LOCAL_MACHINE\ System\CurrentControlSet\Control\TimeZoneInformation\ StandardName SETX /S system /U user /P password BUILD /K "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\ CurrentVersion\CurrentBuildNumber" /M SETX /F ipconfig.out /X SETX IPADDR /F ipconfig.out /A 5,11 SETX OCTET1 /F ipconfig.out /A 5,3 /D "#$*." SETX IPGATEWAY /F ipconfig.out /R 0,7 Gateway SETX /S system /U user /P password /F c:\ipconfig.out /X
|