尽管UFT脚本已完成,Windows任务仍继续运行

尽管UFT脚本已完成,Windows任务仍继续运行,windows,vbscript,qtp,hp-uft,taskscheduler,Windows,Vbscript,Qtp,Hp Uft,Taskscheduler,我正在尝试创建一个任务,该任务将运行一个脚本来启动每天运行的UFT(统一功能测试)。我的脚本正确启动UFT运行到完成,并提供我在Powershell中验证过的退出代码。以下是VBS脚本: testResourcePath = "D:\testnow\code\" 'Getting the test path Dim objArgs Set objArgs = wscript.Arguments testPath = objArgs(0) 'Determining that the

我正在尝试创建一个任务,该任务将运行一个脚本来启动每天运行的UFT(统一功能测试)。我的脚本正确启动UFT运行到完成,并提供我在Powershell中验证过的退出代码。以下是VBS脚本:

testResourcePath = "D:\testnow\code\"


'Getting the test path

Dim objArgs

Set objArgs = wscript.Arguments

testPath = objArgs(0)



'Determining that the test does exist

Dim objFSO

Set objFSO = CreateObject("Scripting.FileSystemObject")

DoesFolderExist = objFSO.FolderExists(testPath)

Set objFSO = Nothing




If DoesFolderExist Then

    Dim uftApp 'Declare the Application object variable

    Dim uftTest 'Declare a Test object variable

    Set uftApp = CreateObject("QuickTest.Application") 'Create the Application object

    uftApp.Launch 'Start QuickTest

    uftApp.Visible = true 'Make the QuickTest application visible

    'Associating function libraries
    uftApp.Open testPath + "\fakepath", False, False
    Set objLib = uftApp.Test.Settings.Resources.Libraries
    'If the library is not already associated with the test case, associate it..
    If objLib.Find(testPath + "\fakepath\ErrorHandlingLibrary.qfl") = -1 Then ' If library is not already added
        objLib.Add testPath + "\fakepath\ErrorHandlingLibrary.qfl", 1 
        objLib.Add testPath + "\fakepath\ObjectDefinitionLibrary.qfl", 1
        objLib.Add testPath + "\fakepath\TestFunctionLibrary.qfl", 1 
        objLib.Add testPath + "\fakepath\UtilityLibrary.qfl", 1 
    End If

    'uftApp.Open testPath, False 'Open the test in read-only mode

    Set uftTest = uftApp.Test

    Set uftResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object

    uftResultsOpt.ResultsLocation = testResourcePath ' Specify the location to save the test results.

    uftTest.Run uftResultsOpt,True 'Run the test and wait until end of the test run

    Dim returnCode
    If uftTest.LastRunResults.Status = "Failed" Then
        'qtTest.Run 'Run the test
        uftTest.Close 'Close the test
        returnCode = 1
    Else

        returnCode = 0
    End If
    uftTest.Close 'Close the test
    uftApp.Quit
    WScript.Echo "Closing Test"
Else

    'Couldn't find the test folder. That's bad. Guess we'll have to report on how we couldn't find the test.

    'Insert reporting mechanism here.

End If

WScript.Quit(returnCode)

尽管如此,任务仍在继续运行,我必须在任务计划程序中手动结束任务。我不确定这是脚本本身的问题还是UFT的问题,我对VBS的UFT都不太熟悉

根据您的问题陈述,我猜测与任务调度程序有关。您是否可以检查以下设置,taskscheduler->yourtask->properties->settings,查看重试复选框是否已启用。当您说task正在运行时,是否意味着UFT在完成后不会关闭?还是测试执行挂起?