批处理修改机器名:
@echo off
set /p name=Please enter your new computer name:
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d %name% /f >nul 2>nul
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %name% /f >nul 2>nul
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d %name% /f >nul 2>nul
echo.
echo Change computer successfully!
echo.
批处理修改环境变量:
更改Path环境变量值,新增:C:\Program Files\Java\jdk1.6.0_10\bin
wmic ENVIRONMENT where "name='path' and username='<system>'" set VariableValue="%path%;C:\Program Files\Java\jdk1.6.0_10\bin"
批处理添加环境变量: wmic ENVIRONMENT create name="PathName",username="<system>",VariableValue="Path"
echo %PathName%
注释: 添加system 环境变量 PathName表示变量的名字,path表示指向的路径,<system>表示添加的是系统环境变量。
例如: wmic ENVIRONMENT create name="JAVA_HOME",username="<system>",VariableValue="D:\jdk1.6.5"