일반적으로 시스템 환경변수를 설정하기 위해서는 내컴퓨터 - 속성 - 고급 - 환경변수 에서 시스템 변수 항목에서 새로 만들기나 편집을 통해서 하게 됩니다.

이런 번거로운 작업을 cmd 창에서 편하게 하기 위해서는 setx 라는 명령어를 사용하면 됩니다.

setx 는 윈도우 XP에 기본적으로 포함되어 있지 않습니다.

따라서 XP 유저라면 아래의 링크에서 추가팩을 설치해야 합니다.


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\TimeZoneInform
ation\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\C
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

가장 간단하게는 setx ZEXTOR_PATH "C:\zextor" -m 라고 입력하게 되면 아래와 같이 추가되겠죠.




  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기