Set fso = Wscript.CreateObject("Scripting.FileSystemObject") '創(chuàng)建文件系統(tǒng)對(duì)象,用以處理驅(qū)動(dòng)器、文件夾和文件 Set WshShell = Wscript.CreateObject("Wscript.Shell") '創(chuàng)建系統(tǒng)Shell對(duì)象,用以運(yùn)行程序等等 if fso.fileexists("D:/刀劍Online/alreadyexist.txt") then '如果找到文件“D:/刀劍 Online/alreadyexist.txt”則 WshShell.Run("D:/刀劍Online/刀劍Online.exe") '運(yùn)行“D:/刀劍Online/刀劍Online.exe” elseif fso.fileexists("http://gengxin/update/dj.exe") then '否則,如果找到“//gengxin/update/dj.exe”則 WshShell.Run("http://gengxin/update/dj.exe") '運(yùn)行“//gengxin/update/dj.exe” else WshShell.Run("D:/刀劍Online/刀劍Online.exe") '否則運(yùn)行“D:/刀劍Online/刀劍Online.exe” end if '根據(jù)條件執(zhí)行語(yǔ)句結(jié)束
VBS 導(dǎo)入注冊(cè)表,然后執(zhí)行文件
復(fù)制代碼 代碼如下:
dim Wsh Set Wsh = WScript.CreateObject("WScript.Shell") Wsh.RegWrite "HKCU/SOFTWARE/AUDITION/AUTOSTART",0,"REG_DWORD" Wsh.RegWrite "HKCU/SOFTWARE/AUDITION/PATH","G:/網(wǎng)絡(luò)游戲/勁舞團(tuán)1.5","REG_SZ" Wsh.RegWrite "HKCU/SOFTWARE/AUDITION/VERSION",1010,"REG_DWORD" Wsh.run "patcher.exe"
PING內(nèi)網(wǎng) 不通就 執(zhí)行關(guān)機(jī) 的VBS
復(fù)制代碼 代碼如下:
strIP = "192.168.0.254" '被PING的內(nèi)網(wǎng)機(jī)器 Set objShell = CreateObject("WScript.Shell") If Not IsOnline(strIP) Then objShell.run "shutdown -s -t 30 -c "&chr(34)&"機(jī)器即將關(guān)閉"&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