wsryyffs 发表于 2013-12-9 18:01:08

vbs调用脚本报错

本帖最后由 wsryyffs 于 2013-12-10 09:44 编辑

我是用winxp的计划任务来调度vbs脚本,有时报错,有时没有问题。

脚本:

'创建QTP的实例
Set obj = CreateObject("QuickTest.Application")
obj.Launch
'设置QTP的窗口为可见
obj.Visible = True
'将QTP窗口最大化
obj.WindowState = "Maximized"
obj.open "D:\test"   '所需调用的脚本路径和名称
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")
qtResultsOpt.ResultsLocation = "D:\xx\result"   

'运行脚本
obj.Test.Run qtResultsOpt
obj.Quit
Set qtResultsOpt = Nothing   
Set obj=Nothing

报错信息:
---------------------------
Windows Script Host
---------------------------
脚本: D:\work\qtp\kq\run.vbs
行: 32
字符: 1
错误: 服务器出现意外情况。
代码: 80010105
源:(null)
---------------------------
确定   
---------------------------

邱建忠 发表于 2013-12-10 18:28:13

'获取路径
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
road = WshShell.CurrentDirectory & "\"

'Dim xlsApp,wkBook,wkSheet,RowCount,CaseArr(50)
'Set xlsApp=CreateObject("Excel.Application")
'Set wkBook=xlsApp.Workbooks.Open("F:\baison\WORK\bserp\BSERP_PG\QTP\QTP实现\QTP实现\TestData.xls")
'Set wkSheet=wkBook.Worksheets("TestScenario")
'RowCount=wkSheet.usedRange.Rows.Count
'For i=2 To RowCount
'        CaseArr(i-2)=wkSheet.Cells(i,1)
'Next
'wkBook.Close
'xlsApp.Quit
'Set wkSheet=Nothing
'Set wkBook=Nothing
'Set xlsApp=Nothing

Dim qtApp
                Set qtApp = CreateObject("QuickTest.Application")
                qtApp.Launch
                qtApp.Visible = True
               
'For i=0 To UBound(CaseArr)
'        If Not IsEmpty(CaseArr(i)) Then       
                qtApp.Openroad&"QTPRUN", False, False
                'Set qtLibraries = qtApp.Test.Settings.Resources.Libraries
      'qtLibraries.Add "F:\baison\WORK\bserp\BSERP_PG\QTP\QTP实现\QTP实现\QTPRUN\aa.vbs"


                qtApp.Test.run
               
'        End If
'Next
页: [1]
查看完整版本: vbs调用脚本报错