How to Run QTP Script at Scheduled Time ?

Sometimes you need to run your QTP scripts at a scheduled time. We can use the Windows Task Scheduler in order to accomplish this. In order to do this, we need to understand QTP’s object Model (AOM, as explained in the post –

After you are clear with AOM and have created a VBS file that launches QTP and starts the Test run, you need to go to the Windows Task Scheduler (Control Panel -> Administrator Tools -> Task Scheduler)

On reaching the Task Scheduler screen, you need to create a Task from the right section of the screen :-




Then after defining the name of the task in the General Tab,you need to define the Trigger, Action and specify any additional settings. For the purpose of this demo, I’ll be creating a Task that executes at 9:00 AM everyday. For doing this, I need to define the Trigger in the following way :-




After this, I need to specify the VBS file which needs to be run at this scheduled time :-




Any additional settings can be done in the Settings Tab :-



This is all you need to schedule your QTP scripts.

Happy Automating !

Harshit Kohli





2 thoughts on “How to Run QTP Script at Scheduled Time ?

  1. Hi Harshit,
    How to schedule login and logoff to Windows as QTP requires User Interface in order to run? I don’t want to leave my machine logged in all the time so i’d like Task Scheduler to automatically log me in, run qtp script and then log me off the machine.

    1. Hey Mike,

      For doing this, you will need 2 machines – A master and a slave. From the master machine, you can login or logoff the slave machine. The code for doing this goes like this:-

      ‘Login from Master machine
      Set wsh = CreateObject(“Wscript.Shell”)
      wsh.Run(C:\LaunchRDP ” & Slave_Name & ” 3389 “& username &” “& domain &” “& password &” 0 0 0″)
      Set wsh

      ‘You can download LaunchRDP.exe from

      ‘Logoff from Slave Machine
      Set wShell = CreateObject(“Wscript.Shell”)

      ‘Force Logoff Computer
      wShell.Run “cmd.exe /c shutdown -f -l”

      Set wShell=Nothing

      Hope this helps 🙂

      Happy Automating,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s