Wednesday, June 2, 2010

QTP - Issue while executing scripts on locked system (Ctr+Alt+Del)

QTP - Issue while executing scripts on locked system (Ctr+Alt+Del)

HP explanation for the above issue.

You may be able to start a script running, then lock your machine. However, there is no guarantee that QuickTest Professional will be able to interact with a GUI application on a locked machine. The application under test may also not function as expected when a machine is locked.

When the machine is locked, the windows operating system disables windows messages, including mouse and the keyboard messages. Some QuickTest Professional methods use these system messages to communicate and interact with the application. On a locked system, these QuickTest Professional methods are unable to replay. This is a limitation of the O/S that is preventing the QuickTest Professional script to replay in a locked mode.

However, if the application supports using events that are not windows messages (such as web events), you may have some success with replay. If any of the methods use system messages internally (i.e., in the compiled code), they will fail. Checkpoints and functions to retrieve text or other properties are likely to fail also.

If you are concerned about security, the current options would be either to keep the machine in a locked room, or remove means of interacting with the machine, such as the keyboard, and/or mouse. QuickTest Professional should still be able to replay without these devices plugged into the machine. You can also lock the keyboard and mouse from within the script.

Following are some of the solutions:

1. I prefer using Caffeine. It is a small program that prevent your PC from activating a screen saver or locking up. You can place it in the "All Programs - Start-up" so that it get activated once you start your PC.
It is light weight(11K) and free to download, attaching the link.
Download Caffeine

Double-click the downloaded file (caffeine.exe), you will notice a "Coffee Mug" icon in the Icon tray.

If you don't want Caffieine, double-click on the icon, "Coffee Mug get emptied" and deactivated.

2. If you edit the follow in the windows registry, it becomes possible for QTP to initialize a test, even though the PC is locked.
HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest and locate the key "SkipEnvironmentChecks"
SkipEnvironmentChecks must be changed from 0 to 1.
This will make QTP ignore that the pc running the test is locked.

3. Execute the following script by saving as .vbs file.

set objUser = GetObject("WinNT://" & strDomain & "/" & strUsername)
if objUser.IsAccountLocked = TRUE then
  objUser.IsAccountLocked = FALSE
  WScript.Echo "Account unlocked"
  WScript.Echo "Account not locked"
end if
4. Execute the following script by saving as .vbs file through windows scheduler.

Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.SendKeys "^%{F1}"
5. Setting up a virtual machine using VMWare or VirtualBox (without a screensaver or lock password) and
install QTP within that virtual machine.
Then you can lock your workstation (maintaining any security) and
still run tests.

6. Installing Admin Pack installed for Windows XP. Admin pack basically enables the OS activites to operate independently of the ongoing process.
Thus the execution process still continues to have focus even if the system gets locked.
Microsoft Download Center Link.
(I have not tested this method)

7. Using Mouse Jiggler



  1. Hey Bharath,

    What do your Steps 3 and 4 do?


  2. Hello Rishi,

    Own creation of STEP 1, but difficult to manage. Need to go in the task manager to check the execution status.

  3. HI Bharat,

    Can you please shed some more light on running QTP tests on Virtual Machines