@echo off
SETX -m JAVA_HOME "C:\Program Files\Java\jdk1.6.0_31"
pause
将在windows xp sp3中运行setx吗?以及如何在xp中以管理员身份运行命令提示符?
答案 0 :(得分:3)
SETX
不是本机Windows XP命令,但它附带Windows XP Pro的支持工具 CD。 http://www.microsoft.com/en-us/download/details.aspx?id=18546
在命令行中尝试SETX /?
并阅读在线帮助
使用RUNAS
命令运行具有管理员权限的程序。见http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/runas.mspx?mfr=true
使用管理员权限启动命令提示符RUNAS /user:HERO cmd.exe
答案 1 :(得分:3)
setx
下载页面:Windows XP Service Pack 2 Support Tools。
命令行语法:Technet
SS64:永久设置环境变量,SETX可用于设置机器(HKLM)或当前登录用户(HKCU)的环境变量Syntax
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
示例消息:
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\TimeZoneInformation\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\CurrentBuildNumber" 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