vbs脚本
程序员文章站
2022-03-04 20:30:52
...
【1】获取本机IP.vbs,并打开驱动盘
'获取本机 IP地址:返回值与函数名相同即可
Function GetLocalIP()
Dim objWMIService,colItems,objItem,objAddress
Set objWMIService = GetObject("winmgmts://./root/cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
For Each objAddress in objItem.IPAddress
If objAddress <> "" then
GetLocalIP = objAddress
End If
Exit For
Next
Exit For
Next
End Function
set StartShell = WScript.CreateObject("WScript.Shell")
'后面加了0,就不弹出各个盘的资源管理界面
StartShell.Run "U:", 0
StartShell.Run "W:", 0
'StartShell.Run "X:", 0
StartShell.Run "Y:", 0
'StartShell.Run "Z:", 0
Msgbox GetLocalIP, ,"本机地址"
【2】自动化脚本
【2.1】svncmd.bat
@echo off
@set LOCAL_PATH=%1
@set OLD_TAG_PATH=%2
@set NEW_TAG_PATH=%3
@set CODE_FROM_SVN=%4
@set USER_NAME=%5
@set ERROR_LOG=SvnError.txt
@set RESUlT=Result.txt
@if "%LOCAL_PATH%"=="" (
@echo "[Error]svncmd.bat(11) 未带参数"
@echo "[Error]svncmd.bat(11) 未带参数" > %RESUlT%
@pause
@exit
) else (
svn info %LOCAL_PATH% 2>%ERROR_LOG% 1>%RESUlT%
for /f "delims=" %%a in (%ERROR_LOG%) do (
if not "%%a"=="" (
@echo "[SvnError]svncmd.bat(19) SVN路径:LocalPath不存在:"
@echo %LOCAL_PATH%
@echo "[SvnError]svncmd.bat(19) SVN路径:LocalPath不存在:" > %RESUlT%
@echo %LOCAL_PATH% >> %RESUlT%
@pause
@exit
)
)
)
@echo [1]LocalPath正常!&@echo [1]LocalPath正常!>>%RESUlT%
@if "%OLD_TAG_PATH%"=="" (
@echo "[Error]svncmd.bat(31)LocalPath, OldTagPath, NewTagPath, CodeFromSVN, UserName其中四个为空 "
@echo "[Error]svncmd.bat(31)LocalPath, OldTagPath, NewTagPath, CodeFromSVN, UserName其中四个为空 " > %RESUlT%
@pause
@exit
) else (
svn info %OLD_TAG_PATH% 2>%ERROR_LOG% 1>>%RESUlT%
for /f "delims=" %%a in (%ERROR_LOG%) do (
if not "%%a"=="" (
@echo "[SvnError]svncmd.bat(39) SVN路径:OldTagPath不存在:"
@echo %OLD_TAG_PATH%
@echo "[SvnError]svncmd.bat(39) SVN路径:OldTagPath不存在:" > %RESUlT%
@echo %OLD_TAG_PATH% >> %RESUlT%
@pause
@exit
)
)
)
@echo [2]OldTagPath正常! &@echo [2]OldTagPath正常!>>%RESUlT%
@if "%NEW_TAG_PATH%"=="" (
@echo "[Error]svncmd.bat(51)LocalPath, OldTagPath, NewTagPath, CodeFromSVN, UserName其中三个为空 "
@echo "[Error]svncmd.bat(51)LocalPath, OldTagPath, NewTagPath, CodeFromSVN, UserName其中三个为空 " > %RESUlT%
@pause
@exit
) else (
svn info %NEW_TAG_PATH% 2>%ERROR_LOG% 1>>%RESUlT%
for /f "delims=" %%a in (%ERROR_LOG%) do (
if not "%%a"=="" (
goto Next
)
)
@echo "[SvnError]svncmd.bat(63) SVN路径:NewTagPath已存在:"
@echo %NEW_TAG_PATH%
@echo "[SvnError]svncmd.bat(63) SVN路径:NewTagPath已存在:" > %RESUlT%
@echo %NEW_TAG_PATH% >> %RESUlT%
@pause
@exit
)
:Next
@echo [3]NewTagPath正常! &@echo [3]NewTagPath正常!>>%RESUlT%
@if "%CODE_FROM_SVN%"=="" (
@echo "[Error]svncmd.bat(73)LocalPath, OldTagPath, NewTagPath, CodeFromSVN, UserName其中两个为空 "
@echo "[Error]svncmd.bat(73)LocalPath, OldTagPath, NewTagPath, CodeFromSVN, UserName其中两个为空 " > %RESUlT%
@pause
@exit
)
@if "%USER_NAME%"=="" (
@echo "[Error]svncmd.bat(81)LocalPath, OldTagPath, NewTagPath, CodeFromSVN, UserName其中一个为空 "
@echo "[Error]svncmd.bat(81)LocalPath, OldTagPath, NewTagPath, CodeFromSVN, UserName其中一个为空 " > %RESUlT%
@pause
@exit
)
@rem svn upgrade %LOCAL_PATH%
svn update --username %USER_NAME% --force --quiet %LOCAL_PATH% 2>%ERROR_LOG% 1>>%RESUlT%
for /f "delims=" %%a in (%ERROR_LOG%) do (
if not "%%a"=="" (
@echo "[SvnError]svncmd.bat(90) SVN更新出错." &@echo "[SvnError]svncmd.bat(90) SVN更新出错." > %RESUlT%
@pause
@exit
)
)
@echo [4]SVN 更新完成! &@echo [4]SVN 更新完成! >>%RESUlT%
svn commit --file 1CommitLog.txt %LOCAL_PATH% 2>%ERROR_LOG% 1>>%RESUlT%
for /f "delims=" %%a in (%ERROR_LOG%) do (
if not "%%a"=="" (
@echo "[SvnError]svncmd.bat(100) SVN提交出错." &@echo "[SvnError]svncmd.bat(100) SVN提交出错." > %RESUlT%
@pause
@exit
)
)
svn update --username %USER_NAME% --force --quiet %LOCAL_PATH%
svn log --revision COMMITTED %LOCAL_PATH% 2>%ERROR_LOG% 1>>%RESUlT%
@echo [5]SVN 提交完成! &@echo [5]SVN 提交完成! >>%RESUlT%
svn delete %OLD_TAG_PATH% -m "delete the old tag: "%OLD_TAG_PATH% 2>%ERROR_LOG% 1>>%RESUlT%
@echo [6]SVN 旧标签删除完成! &@echo [6]SVN 旧标签删除完成! >>%RESUlT%
svn copy %LOCAL_PATH% %NEW_TAG_PATH% --file 2TagLog.txt 2>%ERROR_LOG% 1>>%RESUlT%
svn log %NEW_TAG_PATH% -l 1 2>%ERROR_LOG% 1>>%RESUlT%
@echo [7]SVN 打新标签完成! & @echo [7]SVN 打新标签完成! >>%RESUlT%
@if not exist %CODE_FROM_SVN% mkdir %CODE_FROM_SVN%
svn export -q --username %USER_NAME% --force %NEW_TAG_PATH% %CODE_FROM_SVN% 2>%ERROR_LOG% 1>>%RESUlT%
@echo [8]SVN 从新标签拉代码完成! &@echo [8]SVN 从新标签拉代码完成! >>%RESUlT%
@pause
【2.2】自动打标签.bat
@rem 待提交的代码路径
@set LocalPath=
@rem 旧标签所在路径
@set OldTagPath=
@rem 新标签所在路径
@set NewTagPath=
@rem 从SVN上拉代码后存放位置,验证SVN代码是否编译正常
@set CodeFromSVN=
@rem 具有SVN权限的用户名
@set UserName=
@call svncmd.bat %LocalPath% %OldTagPath% %NewTagPath% %CodeFromSVN% %UserName%
【2.3】1CommitLog.txt 2TagLog.txt Result.txt SvnError.txt
上一篇: python编写时怎么换行
下一篇: iOS只分享到微博的解决方法