Sign in with
Sign up | Sign in
Your question

Setting DOS environment variables

Last response: in Windows XP
Share
Anonymous
August 22, 2005 6:26:01 PM

Archived from groups: microsoft.public.windowsxp.general (More info?)

How can I set DOS environment variables upon logging into Windows or the
network. Currently the environment variables are being set in the
autoexec.nt batch file but they are global for all users...ex:

SET FULL_NAME=JOE BLOW
SET LOGIN_NAME=JOE

I would like to set the user's login name and full name and a couple of
other settings. I noticed that USERNAME is a setting when I enter SET
from the DOS command line.

Should I create a batch file in the autoexec that calls a batch file in
the user's profile directory based upon the USERNAME?

This was easy for me to do with Novell since there was a User login
script that was executed upon logging in. Is there something similar in
WinXP?
Anonymous
August 22, 2005 8:41:51 PM

Archived from groups: microsoft.public.windowsxp.general (More info?)

Hi Salad

You're rather mixed 'cos you can not use DOS autoexec.bat in Windows.
Once you are loaded in Windows, click start\help and look up user management
--
Uncle John
"Salad" <oil@vinegar.com> wrote in message
news:ZflOe.63$z2.4@newsread3.news.pas.earthlink.net...
> How can I set DOS environment variables upon logging into Windows or the
> network. Currently the environment variables are being set in the
> autoexec.nt batch file but they are global for all users...ex:
>
> SET FULL_NAME=JOE BLOW
> SET LOGIN_NAME=JOE
>
> I would like to set the user's login name and full name and a couple of
> other settings. I noticed that USERNAME is a setting when I enter SET
> from the DOS command line.
>
> Should I create a batch file in the autoexec that calls a batch file in
> the user's profile directory based upon the USERNAME?
>
> This was easy for me to do with Novell since there was a User login script
> that was executed upon logging in. Is there something similar in WinXP?
Anonymous
August 22, 2005 8:41:52 PM

Archived from groups: microsoft.public.windowsxp.general (More info?)

Windows XP looks at Autoexec.bat.

The only lines in Autoexec.bat that Windows XP will read are the lines that
begin with SET or PATH. If ParseAutoexec is set to 1.

When this value is enabled the variables listed in the Autoexec.bat file
will be parsed and included in the current user environment.

HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Winlogon
Value Name: ParseAutoexec
Data Type: REG_SZ
Data: 0 or 1
0 : Ignores Autoexec.bat at logon.
1 : Parses Autoexec.bat at logon.

This has no effect on the parsing of AUTOEXEC.NT or CONFIG.NT by the MS-DOS
or 16-bit Windows environments (VDMs).

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In news:o jPmFAzpFHA.1416@TK2MSFTNGP12.phx.gbl,
Uncle John <unclejohn@uselesnospam.com> hunted and pecked:
> Hi Salad
>
> You're rather mixed 'cos you can not use DOS autoexec.bat in Windows.
> Once you are loaded in Windows, click start\help and look up user
> management --
> Uncle John
> "Salad" <oil@vinegar.com> wrote in message
> news:ZflOe.63$z2.4@newsread3.news.pas.earthlink.net...
>> How can I set DOS environment variables upon logging into Windows or the
>> network. Currently the environment variables are being set in the
>> autoexec.nt batch file but they are global for all users...ex:
>>
>> SET FULL_NAME=JOE BLOW
>> SET LOGIN_NAME=JOE
>>
>> I would like to set the user's login name and full name and a couple of
>> other settings. I noticed that USERNAME is a setting when I enter SET
>> from the DOS command line.
>>
>> Should I create a batch file in the autoexec that calls a batch file in
>> the user's profile directory based upon the USERNAME?
>>
>> This was easy for me to do with Novell since there was a User login
>> script that was executed upon logging in. Is there something similar in
>> WinXP?
Related resources
Anonymous
August 22, 2005 11:38:08 PM

Archived from groups: microsoft.public.windowsxp.general (More info?)

User specific environment variables can be set from My computer ->
properties -> advanced -> environment variables. But when you want to do it
from script, you need another way. You could perhaps create a script and
make shortcut to start menu -> propgrams -> startup. Use folder C:\Documents
and Settings\All Users\Start Menu\Programs\Startup, if you want to make it
availabe for all users.

Anyway, don't use simple set command in script. Instead, get windows
resource kit, which has setx.exe. With it you can set environment variables
from scripts so that those settings are visible also outside of the
executing script. here is setx help:

c:\>setx /?

SETX: This program is used to set values in the environment
of the machine or currently logged on user using one of three modes.

1) Command Line Mode: setx variable value [-m]
Optional Switches:
-m Set value in the Machine environment. Default is User.

2) Registry Mode: setx variable -k hive\key\...\value
Optional Switches:
-m Set value in the Machine environment. Default is User.

3) File Mode: setx variable -f file {-a x,y | -r x,y "string"} [-d d] [-x]
[-m]
Required Switches:
-f file : Specify file name to use.
-a x,y : Specify absolute coordinates and offset.
-r x,y "string" : Specify coordinates and offset relative to string.
Optional Switches
-d ,:\ etc. : Specify additional delimiters.
-x : Displays file coordinates. Switches -a -r -e ignored!!
-m : Set value in the Machine environment. Default is User.

SETX Examples:
--------------
To view the examples screen best set the width of your command window to
100.

For the file type examples you must first create the file that you wish to
parse by using "command > filename" ie ipconfig > ipconfig.out.

IMPORTANT: SETX writes variables to the master environment in the registry.
Variables set using SETX are only available in future command windows and
not in the current command window.



SETX Command Line Examples:
--------------------------
SETX MACHINE COMPAQ
Sets value of MACHINE to be COMPAQ in the users environment.

SETX MACHINE "COMPAQ COMPUTER" -m
Sets value of MACHINE to be "COMPAQ COMPUTER" in the machine environment.

SETX MYPATH %PATH%
Sets the value of MYPATH to the CURRENT value of the PATH environment
variable.

SETX MYPATH ~PATH~
Sets the value of MYPATH to ALWAYS be equal to the value of the PATH
environment variable even in the event that the PATH variable changes.



SETX Registry Examples:
-------------------
SETX TZONE -k
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInforation\StandardName
Sets the value of TZONE to the above key ie. "Central Standard Time"

SETX BUILD -k "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows
NT\CurrentVersion\urrentBuildNumber"
Sets the value of BUILD to the current Windows NT build ie. "1314"
Note: Quotes must be used because of the embedded space in "Windows NT".



SETX File Examples:
-------------------
SETX VAR -f ipconfig.out -x
Displays the coordinates for the contents of the file "ipconfig.out".

SETX IPADDR -f ipconfig.out -a 5,11
Finds value at absolute offset 5,11 of the file ipconfig.out
Sets IPADDR to the IP Address (absolute offset 5,11)

SETX OCTET1 -f ipconfig.out -a 5,3 -d .
Finds value at absolute offset 5,3 and uses "." as an additional delimiter.
Sets OCTET1 to the first octet of the IP Address

SETX IPGATEWAY -f ipconfig.out -r 0,7 "Gateway"
Finds value at relative offset 0,7 to the keyword "Gateway"
Sets IPGATEWAY to the first octet of the IP Address


SETX: Version 1.0a (5/31/96)
Gary Milne - Microsoft MCS




"Salad" <oil@vinegar.com> wrote in message
news:ZflOe.63$z2.4@newsread3.news.pas.earthlink.net...
> How can I set DOS environment variables upon logging into Windows or the
> network. Currently the environment variables are being set in the
> autoexec.nt batch file but they are global for all users...ex:
>
> SET FULL_NAME=JOE BLOW
> SET LOGIN_NAME=JOE
>
> I would like to set the user's login name and full name and a couple of
> other settings. I noticed that USERNAME is a setting when I enter SET
> from the DOS command line.
>
> Should I create a batch file in the autoexec that calls a batch file in
> the user's profile directory based upon the USERNAME?
>
> This was easy for me to do with Novell since there was a User login script
> that was executed upon logging in. Is there something similar in WinXP?
Anonymous
August 22, 2005 11:38:09 PM

Archived from groups: microsoft.public.windowsxp.general (More info?)

setx.exe is also part of Windows Support Tools.

Windows Support Tools is on the XP CD.

Drive letter:\SUPPORT\TOOLS

Along with many useful tools built into the Windows operating system, over
40 additional Support Tools are included on the Windows CD.

To install Windows Support Tools
http://www.microsoft.com/resources/documentation/window...

Windows Support Tools
http://www.microsoft.com/windowsxp/home/using/productdo...

Using the Windows XP support tools
http://support.microsoft.com/default.aspx?scid=%2fdirec...

Windows XP Service Pack 2 Support Tools
http://www.microsoft.com/downloads/details.aspx?FamilyI...



--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In news:%23lLTefzpFHA.720@tk2msftngp13.phx.gbl,
News Reader <stealth@null.net> hunted and pecked:
> User specific environment variables can be set from My computer ->
> properties -> advanced -> environment variables. But when you want to do
> it from script, you need another way. You could perhaps create a script
> and make shortcut to start menu -> propgrams -> startup. Use folder
> C:\Documents and Settings\All Users\Start Menu\Programs\Startup, if you
> want to make it availabe for all users.
>
> Anyway, don't use simple set command in script. Instead, get windows
> resource kit, which has setx.exe. With it you can set environment
> variables from scripts so that those settings are visible also outside of
> the executing script. here is setx help:
>
> c:\>setx /?
>
> SETX: This program is used to set values in the environment
> of the machine or currently logged on user using one of three modes.
>
> 1) Command Line Mode: setx variable value [-m]
> Optional Switches:
> -m Set value in the Machine environment. Default is User.
>
> 2) Registry Mode: setx variable -k hive\key\...\value
> Optional Switches:
> -m Set value in the Machine environment. Default is User.
>
> 3) File Mode: setx variable -f file {-a x,y | -r x,y "string"} [-d d] [-x]
> [-m]
> Required Switches:
> -f file : Specify file name to use.
> -a x,y : Specify absolute coordinates and offset.
> -r x,y "string" : Specify coordinates and offset relative to string.
> Optional Switches
> -d ,:\ etc. : Specify additional delimiters.
> -x : Displays file coordinates. Switches -a -r -e ignored!!
> -m : Set value in the Machine environment. Default is User.
>
> SETX Examples:
> --------------
> To view the examples screen best set the width of your command window to
> 100.
>
> For the file type examples you must first create the file that you wish to
> parse by using "command > filename" ie ipconfig > ipconfig.out.
>
> IMPORTANT: SETX writes variables to the master environment in the
> registry. Variables set using SETX are only available in future command
> windows and not in the current command window.
>
>
>
> SETX Command Line Examples:
> --------------------------
> SETX MACHINE COMPAQ
> Sets value of MACHINE to be COMPAQ in the users environment.
>
> SETX MACHINE "COMPAQ COMPUTER" -m
> Sets value of MACHINE to be "COMPAQ COMPUTER" in the machine environment.
>
> SETX MYPATH %PATH%
> Sets the value of MYPATH to the CURRENT value of the PATH environment
> variable.
>
> SETX MYPATH ~PATH~
> Sets the value of MYPATH to ALWAYS be equal to the value of the PATH
> environment variable even in the event that the PATH variable changes.
>
>
>
> SETX Registry Examples:
> -------------------
> SETX TZONE -k
>
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInforation\Stand
ardName
> Sets the value of TZONE to the above key ie. "Central Standard Time"
>
> SETX BUILD -k "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows
> NT\CurrentVersion\urrentBuildNumber"
> Sets the value of BUILD to the current Windows NT build ie. "1314"
> Note: Quotes must be used because of the embedded space in "Windows NT".
>
>
>
> SETX File Examples:
> -------------------
> SETX VAR -f ipconfig.out -x
> Displays the coordinates for the contents of the file "ipconfig.out".
>
> SETX IPADDR -f ipconfig.out -a 5,11
> Finds value at absolute offset 5,11 of the file ipconfig.out
> Sets IPADDR to the IP Address (absolute offset 5,11)
>
> SETX OCTET1 -f ipconfig.out -a 5,3 -d .
> Finds value at absolute offset 5,3 and uses "." as an additional
> delimiter. Sets OCTET1 to the first octet of the IP Address
>
> SETX IPGATEWAY -f ipconfig.out -r 0,7 "Gateway"
> Finds value at relative offset 0,7 to the keyword "Gateway"
> Sets IPGATEWAY to the first octet of the IP Address
>
>
> SETX: Version 1.0a (5/31/96)
> Gary Milne - Microsoft MCS
>
>
>
>
> "Salad" <oil@vinegar.com> wrote in message
> news:ZflOe.63$z2.4@newsread3.news.pas.earthlink.net...
>> How can I set DOS environment variables upon logging into Windows or the
>> network. Currently the environment variables are being set in the
>> autoexec.nt batch file but they are global for all users...ex:
>>
>> SET FULL_NAME=JOE BLOW
>> SET LOGIN_NAME=JOE
>>
>> I would like to set the user's login name and full name and a couple of
>> other settings. I noticed that USERNAME is a setting when I enter SET
>> from the DOS command line.
>>
>> Should I create a batch file in the autoexec that calls a batch file in
>> the user's profile directory based upon the USERNAME?
>>
>> This was easy for me to do with Novell since there was a User login
>> script that was executed upon logging in. Is there something similar in
>> WinXP?
Anonymous
August 23, 2005 2:47:06 AM

Archived from groups: microsoft.public.windowsxp.general (More info?)

Uncle John wrote:

> Hi Salad
>
> You're rather mixed 'cos you can not use DOS autoexec.bat in Windows.
> Once you are loaded in Windows, click start\help and look up user management

Thanks for responding. I don't use Autoexec.BAT but I do use
Autoexec.NT which is working fine to set the environment variables. But
it is global specific, not user specific.

I'll see If I can call a batch file in Autoexec.NT that passes the user
login name.
Anonymous
August 23, 2005 2:57:45 AM

Archived from groups: microsoft.public.windowsxp.general (More info?)

Wesley Vogel wrote:

> setx.exe is also part of Windows Support Tools.
>
> Windows Support Tools is on the XP CD.
>
> Drive letter:\SUPPORT\TOOLS
>
> Along with many useful tools built into the Windows operating system, over
> 40 additional Support Tools are included on the Windows CD.
>
> To install Windows Support Tools
> http://www.microsoft.com/resources/documentation/window...
>
> Windows Support Tools
> http://www.microsoft.com/windowsxp/home/using/productdo...
>
> Using the Windows XP support tools
> http://support.microsoft.com/default.aspx?scid=%2fdirec...
>
> Windows XP Service Pack 2 Support Tools
> http://www.microsoft.com/downloads/details.aspx?FamilyI...
>
Thanks all for the info.
!