使用VBScript抑制对话框

时间:2017-08-14 17:35:46

标签: vbscript

我有一个自动化测试程序,它使用SOAPUI,使用VBScript执行。但是,每当我执行测试程序时,都会打开一个SOAPUI对话框,询问“您是否希望通过发送使用情况统计信息来帮助我们改进SOAPUI”。我手动点击“否”,测试程序一直在运行。

有没有办法抑制此对话框,以便在运行自动化测试程序时它永远不会出现。 VBScript代码如下。

Option Explicit

Dim RootFolder, ExecFolder, Command, FSO, Shell

Set FSO = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("WScript.Shell")

RootFolder = FSO.GetParentFolderName(FSO.GetParentFolderName(WScript.ScriptFullName))
ExecFolder = FSO.GetParentFolderName(WScript.ScriptFullName)

On Error Resume Next

'Clean previous log files
Call FSO.DeleteFile(ExecFolder & "\*.txt", True)
Call FSO.DeleteFile(RootFolder & "\Test\*.txt", True)
Call FSO.DeleteFile(ExecFolder & "\*.log", True)

'Execute
Command = Chr(34) & RootFolder & "\SoapUI\bin\testrunner.bat" & Chr(34) & " " & _
          Chr(34) & RootFolder & "\Test\Expando.xml" & Chr(34)

Shell.CurrentDirectory = ExecFolder
Call Shell.Run(Command, 1, True)

1 个答案:

答案 0 :(得分:0)

我已使用SendKeys解决了这个问题。

OPTION EXPLICIT

Dim RootFolder, ExecFolder, Command, FSO, Shell

Set FSO = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("WScript.Shell")

RootFolder = FSO.GetParentFolderName(FSO.GetParentFolderName(Wscript.ScriptFullName))
ExecFolder = FSO.GetParentFolderName(Wscript.ScriptFullName)

On Error Resume Next

'Clean previous log files
Call FSO.DeleteFile(ExecFolder & "\*.txt", True)
Call FSO.DeleteFile(RootFolder & "\Test\*.txt", True)
Call FSO.DeleteFile(ExecFolder & "\*.log", True)

'Execute
Command = Chr(34) & RootFolder &  "\SoapUI\bin\testrunner.bat" & Chr(34) & " " & Chr(34) & RootFolder & "\Test\Expando.xml" & Chr(34)

Shell.CurrentDirectory = ExecFolder
Call Shell.Run(Command, 1, False)
WScript.Sleep(20000)
Shell.SendKeys("~")