简体   繁体   中英

Calling a batch script from a vbscript script

I am trying to call a batch file from VBS, but I keep getting this "object required" error:

Line: 4
Char: 1
Error: Object Required: 'wshshell'
Code: 800A01A8

VBS just won't let me call it, no matter what I do. Here is the code I am currently using:

X=MsgBox("Scan For Malware?",vbYesNo,"InSYS AntiVirus")
if x=6 Then

wshshell.run "InSys AntiVirus.bat"

End if

if x=7 Then
wscript.quit

end if

The error occurs because you have not created any object named wshshell .

To run a CMD batch file from VBScript:

Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "InSys AntiVirus.bat"

Source: http://ss64.com/vb/syntax-run.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM