@echo off
mode con lines=30 cols=60
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"
pause
批量创建环境变量
@echo off
wmic ENVIRONMENT where "name='JRE64_HOME'" delete
wmic ENVIRONMENT where "name='TC_JRE_HOME'" delete
wmic ENVIRONMENT create name="TC_JRE_HOME",username="<system>",VariableValue="C:\Java\jre7"
wmic ENVIRONMENT create name="JRE64_HOME",username="<system>",VariableValue="C:\Java\jre7"
pause
hosts文件关键词删除行
@echo off
set Row=
set Str=
set "Xstr=BEARTCTEXT"
set "Files=C:\Windows\System32\drivers\etc\hosts"
set "OutputFiles=C:\Windows\System32\drivers\etc\$"
if exist "%Files%" (
setlocal enabledelayedexpansion
for /f "delims=" %%a in (%Files%) do (
set/a Row+=1 & set "Str=%%a"
((echo !Str! | findstr /i "!Xstr!">nul) && (
echo Found target text.(发现目标文字!)
)) || (
echo !Str!>>!OutputFiles!
)
))
move !OutputFiles! %Files%>nul 2>nul
echo Completed (执行完毕)!!
pause>nul
批量编辑hosts文件
@echo off
set stHosts=192.168.1.20 plm20
echo.>>%SystemRoot%\system32\drivers\etc\hosts
FOR /F "eol=# tokens=1 delims=" %%i in (%SystemRoot%\system32\drivers\etc\hosts) do if "%stHosts%"=="%%i" exit
echo %stHosts%>> %SystemRoot%\system32\drivers\etc\hosts
pause
生成快捷方式及其图标
echo off
echo 生成快捷方式...
set tcpath=D:\Siemens\Teamcenter\OTW11_TEST\rac\portal.bat
for /f "tokens=2,*" %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop"') do Set a=%%j
echo 你当前桌面路径是:%a%
set todesktopPath=%a%\Teamcenter.url
echo [InternetShortcut] >>%todesktopPath%
echo url="%tcpath%" >>%todesktopPath%
echo IconIndex=0 >>%todesktopPath%
echo IconFile=D:\Siemens\Teamcenter\OTW11_TEST\rac\runner.exe>>%todesktopPath%
echo 快捷方式已生成
pause>nul