Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

vbscript - Cannot use parentheses when calling a Sub Error 800A0414 VBS

I am getting the 800A0414 error in lines 7 and 12 of this script:

Module Module1

  Dim p

    Sub Main()
        CreateObject("Wscript.Shell").Run("program.bat", 0, True)

        p = Process.GetProcessesByName("program")
        If p.Count > 0 Then
            WScript.Sleep(300000)
        Else
            CreateObject("Wscript.Shell").Run("program clean up.bat", 0, True)
        End If

    End Sub

    Private Function WScript() As Object
        Throw New NotImplementedException
    End Function

End Module

I am trying to run a batch script, that starts a process, then wait until the process terminates, then run another batch script. I also do not want any command boxes being shown. If their is a easier way please let me know.

Thanks for your help

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When you enclose a procedure's argument list in parentheses, you must use the Call keyword:

Call CreateObject("WScript.Shell").Run("program.bat", 0, True)

If you omit the Call keyword, you must also drop parentheses:

CreateObject("WScript.Shell").Run "program.bat", 0, True

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...