Set fso = Wscript.CreateObject("Scripting.FileSystemObject") '創建文件系統對象,用以處理驅動器、文件夾和文件 Set WshShell = Wscript.CreateObject("Wscript.Shell") '創建系統Shell對象,用以運行程序等等 if fso.fileexists("D:/刀劍Online/alreadyexist.txt") then '如果找到文件“D:/刀劍 Online/alreadyexist.txt”則 WshShell.Run("D:/刀劍Online/刀劍Online.exe") '運行“D:/刀劍Online/刀劍Online.exe” elseif fso.fileexists("http://gengxin/update/dj.exe") then '否則,如果找到“//gengxin/update/dj.exe”則 WshShell.Run("http://gengxin/update/dj.exe") '運行“//gengxin/update/dj.exe” else WshShell.Run("D:/刀劍Online/刀劍Online.exe") '否則運行“D:/刀劍Online/刀劍Online.exe” end if '根據條件執行語句結束
VBS 導入注冊表,然后執行文件
復制代碼 代碼如下:
dim Wsh Set Wsh = WScript.CreateObject("WScript.Shell") Wsh.RegWrite "HKCU/SOFTWARE/AUDITION/AUTOSTART",0,"REG_DWORD" Wsh.RegWrite "HKCU/SOFTWARE/AUDITION/PATH","G:/網絡游戲/勁舞團1.5","REG_SZ" Wsh.RegWrite "HKCU/SOFTWARE/AUDITION/VERSION",1010,"REG_DWORD" Wsh.run "patcher.exe"
PING內網 不通就 執行關機 的VBS
復制代碼 代碼如下:
strIP = "192.168.0.254" '被PING的內網機器 Set objShell = CreateObject("WScript.Shell") If Not IsOnline(strIP) Then objShell.run "shutdown -s -t 30 -c "&chr(34)&"機器即將關閉"&chr(34) End If Function IsOnline(strComputer) IsOnline = false strCommand = "%comspec% /c ping -n 2 -w 500 " & strComputer & "" Set objExecObject = objShell.Exec(strCommand) Do While Not objExecObject.StdOut.AtEndOfStream strText = objExecObject.StdOut.ReadAll() If Instr(strText, "Reply") > 0 Then IsOnline = true End If Loop End Function