China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-22 18:20
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » System environment variable overview View 1,676 Replies 9
Original Poster Posted 2008-01-26 22:07 ·  中国 广东 梅州 电信
中级用户
★★
Credits 262
Posts 129
Joined 2007-07-11 06:50
18-year member
UID 93679
Gender Male
Status Offline
%allusersprofile% Location of the local "All Users" profile. C:\Documents and Settings\All Users

%appdata% Location where the application stores data by default locally. C:\Documents and Settings\Administrator\Application Data

%cd% Local current directory string. C:\Documents and Settings\Administrator\Desktop

%cmdcmdline% The exact command line used to start the current Cmd.exe. cmd /c ""C:\Documents and Settings\Administrator\Desktop\a.bat" "

%cmdextversion% The version number of the system's current "Command Processor Extensions". 2

%computername% The name of the system computer. xxxxx

%comspec% The exact path to the system command line interpreter executable. C:\WINDOWS\system32\cmd.exe

%date% The current system date. Uses the same format as the date /t command. Generated by Cmd.exe. For more information about the date command, see Date.

%time% The current system time. Uses the same format as the time /t command. Generated by Cmd.exe. For more information about the time command, see Time.

%errorlevel% The error code of the previous command on the system. Usually indicates an error with a non-zero value.

%homedrive% The local workstation drive letter to which the system connects to the user's home directory. Set based on the home directory value. The user's home directory is specified in "Local Users and Groups". C:

%homepath% The full path to the system user's home directory. Set based on the home directory value. The user's home directory is specified in "Local Users and Groups". \Documents and Settings\Administrator

%homeshare% The network path to the user's shared home directory on the system. Set based on the home directory value. The user's home directory is specified in "Local Users and Groups".

%logonserver% The name of the domain controller that authenticates the current logon session locally. \\xxxx

%number_of_processors% The number of processors installed on the system as specified.

%os% The name of the system operating system. Windows 2000 shows its operating system as Windows_NT. Windows_NT

%path% The search path for executable files specified by the system. C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem

%pathext% The list of file extensions that the system operating system considers executable. .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

%processor_architecture% The chip architecture of the system processor. Values: x86 or IA64 based on Itanium x86

%processor_identfier% The system processor description.

%processor_level% The model of the processor installed on the system computer. 15

%processor_revision% The version number of the system processor. 4f02

%prompt% The command prompt setting of the current interpreter locally. Generated by Cmd.exe. $P$G

%random% Any decimal number between 0 and 32767 on the system. Generated by Cmd.exe. 30580

%systemdrive% The drive that contains the root directory (i.e., the system root) of the Windows server operating system. C:

%systemroot% The location of the root directory of the Windows server operating system. C:\WINDOWS

%temp% C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp and %tmp% C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp The default temporary directory used by applications available to the current logged-on user for the system and the user. Some applications require TEMP, while others require TMP.

%userdomain% The name of the domain that contains the user account locally. xxxxxx

%username% The name of the currently logged-on user locally. Administrator

%userprofile% The location of the current user's profile locally. C:\Documents and Settings\Administrator

%windir% The location of the operating system directory. C:\WINDOWS

%programfiles% The location of the program folder. C:\Program Files



----------------------------------------------------------------------------------------------------
If not complete, please supplement. Or if there are errors that can be corrected, please post.
Floor 2 Posted 2008-01-26 22:15 ·  中国 吉林 吉林市 联通
初级用户
Credits 68
Posts 32
Joined 2007-12-09 17:16
18-year member
UID 105152
Gender Male
Status Offline
Floor 3 Posted 2008-01-26 22:25 ·  中国 陕西 西安 电信
新手上路
Credits 10
Posts 4
Joined 2007-08-29 18:11
18-year member
UID 96131
Status Offline
How to configure system environment variables using batch processing?
Floor 4 Posted 2008-01-27 01:10 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Originally posted by zjwplp at 2008-1-26 10:25 PM:
How to configure system environment variables with batch processing?


@echo off
rem Add system environment variable
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v test /t REG_SZ /d "hello world" /f
Floor 5 Posted 2008-03-13 21:17 ·  中国 福建 电信
初级用户
Credits 26
Posts 13
Joined 2008-03-09 13:39
18-year member
UID 112459
Gender Male
Status Offline
Thanks a lot to the LZ, up~~~~~~~
Floor 6 Posted 2008-03-14 01:21 ·  中国 广东 深圳 福田区 电信
新手上路
Credits 10
Posts 5
Joined 2008-03-13 10:58
18-year member
UID 112829
Gender Male
Status Offline
Very useful material, thanks LZ
Floor 7 Posted 2008-03-14 09:13 ·  中国 广东 深圳 联通
初级用户
Credits 89
Posts 36
Joined 2007-12-20 15:37
18-year member
UID 106247
Gender Male
Status Offline
Thanks, you've worked hard...
Floor 8 Posted 2008-03-14 09:58 ·  中国 广东 深圳 电信
初级用户
Credits 84
Posts 32
Joined 2007-09-17 12:42
18-year member
UID 97604
Gender Male
From 湖北
Status Offline
Nice stuff, saved it
Floor 9 Posted 2008-03-14 20:57 ·  中国 北京 海淀区 联通
银牌会员
★★★
Credits 1,287
Posts 634
Joined 2007-05-02 15:06
19-year member
UID 87277
Gender Male
From cmd.exe
Status Offline
Have time might as well take a look at ntcmds.chm

The following table lists the system and local environment variables of Windows XP.

Variable Type Description
%ALLUSERSPROFILE% Local Returns the location of "All Users Profile".
%APPDATA% Local Returns the location where applications store data by default.
%CD% Local Returns the current directory string.
%CMDCMDLINE% Local Returns the exact command line used to start the current Cmd.exe.
%CMDEXTVERSION% System Returns the version number of the current "Command Processor Extension".
%COMPUTERNAME% System Returns the name of the computer.
%COMSPEC% System Returns the exact path of the command-line interpreter executable.
%DATE% System Returns the current date. Uses the same format as the date /t command. Generated by Cmd.exe. For more information about the date command, see Date.
%ERRORLEVEL% System Returns the error code of the most recently used command. Usually indicated by a non-zero value for an error.
%HOMEDRIVE% System Returns the local workstation drive letter connected to the user's home directory. Set based on the home directory value. The user's home directory is specified in "Local Users and Groups".
%HOMEPATH% System Returns the full path of the user's home directory. Set based on the home directory value. The user's home directory is specified in "Local Users and Groups".
%HOMESHARE% System Returns the network path of the user's shared home directory. Set based on the home directory value. The user's home directory is specified in "Local Users and Groups".
%LOGONSEVER% Local Returns the name of the domain controller that authenticates the current logon session.
%NUMBER_OF_PROCESSORS% System Specifies the number of processors installed on the computer.
%OS% System Returns the name of the operating system. Windows 2000 displays the operating system as Windows_NT.
%PATH% System Specifies the search path for executable files.
%PATHEXT% System Returns the list of file extensions that the operating system considers executable.
%PROCESSOR_ARCHITECTURE% System Returns the chip architecture of the processor. Values: x86, IA64.
%PROCESSOR_IDENTFIER% System Returns the processor description.
%PROCESSOR_LEVEL% System Returns the model of the processor installed on the computer.
%PROCESSOR_LEVEL% System Returns the version number of the processor.
%PROMPT% Local Returns the command prompt setting of the current interpreter. Generated by Cmd.exe.
%RANDOM% System Returns any decimal number between 0 and 32767. Generated by Cmd.exe.
%SYSTEMDRIVE% System Returns the drive that contains the Windows XP root directory (i.e., the system root directory).
%SYSTEMROOT% System Returns the location of the Windows XP root directory.
%TEMP% and %TMP% System and User Returns the default temporary directory used by applications available to the current logged-on user. Some applications need TEMP, while others need TMP.
%TIME% System Returns the current time. Uses the same format as the time /t command. Generated by Cmd.exe. For more information about the time command, see Time.
%USERDOMAIN% Local Returns the name of the domain that contains the user account.
%USERNAME% Local Returns the name of the currently logged-on user.
%UserPrefix% Local Returns the location of the current user's profile.
%WINDIR% System Returns the location of the operating system directory.
Floor 10 Posted 2008-03-14 22:42 ·  中国 广东 韶关 电信
初级用户
Credits 114
Posts 36
Joined 2007-12-22 17:42
18-year member
UID 106486
Gender Male
Status Offline
Start - Run - CMD - SET - {ENTER}:
All the environment variables of your computer are there.
Forum Jump: