본문 바로가기

old drawer/programming

[ETC]명령어로 path 환경 변수를 영구히 변경하는 방법

명령어로 path 환경 변수를 영구히 변경하는 방법  

Windows 7

 1

Command Prompt 실행 

 단축키 윈도우키 + R 누르기

 입력창에 cmd 입력하고 확인 버튼 클릭

 2

 setx 명령으로 path 환경 변수에 C:\Program Files\java\jdk1.6.0_26\bin 추가

 

 C:\>setx path "%PATH%;C:\Program Files\java\jdk1.6.0_26\bin"

 3

 Command Prompt 재실행 후 javac 명령 실행

 

 C:\>javac
Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are
sed
  -classpath <path>          Specify where to find user class files and annotat
on processors
  -cp <path>                 Specify where to find user class files and annotat
on processors
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compi
ation is done.
  -processor <class1>[,<class2>,<class3>...]Names of the annotation processors
o run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files
  -implicit:{none,class}     Specify whether or not to generate class files for
implicitly referenced files
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified releas

  -target <release>          Generate class files for specific VM version
  -version                   Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system


C:\>

 

 


 

Windows XP

 1

 다음 vbscript 코드를 envChg.vbs로 저장합니다.

Set WshShell = WScript.CreateObject("WScript.Shell")
strReg = "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path"
strSetting = WshShell.RegRead(strReg)
strNewSetting = strSetting&";C:\Program Files\java\jdk1.6.0_26\bin"    

WScript.Echo strNewSetting
WshShell.RegWrite strReg, strNewSetting

 2

 envChg.vbs 파일을 더블 클릭해서 실행합니다. 

 

참고 :

Modify the PATH Environment Variable in Windows

Microsoft DOS set command

setting the environment path permanently
SETX DOS Command Issue
Default Environment variable Values of Windows 7 / xp
Environment Variables For Java Applications
Command shell overview
CMD.exe