How to read and modify Registry Settings from QTP?


I am back with an Exciting feature of QTP. Sometimes, there are certain settings that you wish that can be configured automatically before running a Test. It also doesn’t make sense to record “activities configuring those settings”. Moreover, if you configure those settings manually in one machine, then you have configure those settings again in other machine if you plan to run test in some other machine.

For example: You want to disable pop up blocker before executing Tests as some pop up windows are getting opened in some of those tests.

To do this automatically using QTP, there is only one requirement: we just have to find out the registry setting that affects the feature that you want to change..

We will take the example of pop up blocker in this case

So, to disable pop up blocker, we just need to change the following registry key to No

“HKCU\Software\Microsoft\Internet Explorer\New Windows\PopupMgr”

We have to create “Windows Shell” object and then access its inbuilt RegRead and RegWrite functions.

As the name suggests, RegRead method allows you to read the value of the specified Registry path and RegWrite allows you to modify the value of the specified registry.

Now, lets do some action:

Dim objShell, RegLocate
<blockquote>'create windows shell object
 Set objshell =CreateObject("WScript.Shell")

'disable pop up blocker in IE if enabled
 RegLocate ="HKCU\Software\Microsoft\Internet Explorer\New Windows\PopupMgr"
 msgbox objshell.RegRead (RegLocate)
 If (objshell.RegRead (RegLocate)="Yes" OR objshell.RegRead (RegLocate)="yes") Then
 objShell.RegWrite RegLocate,"No","REG_SZ"
 End If

Set objshell = Nothing

As you see in the above example, value of the specified registry is displayed using RegRead function and then if pop up blocker is enabled, then it is disabled by modifying the value of corresponding registry key.
Similarly, to configure any other setting (before running test) in any browser, MS office or any other any software, you just need to know the registry setting that affects that particular activity and you are done…

Tagged with: , , , , , , , , , , , , , ,
Posted in Awesum Stuff
3 comments on “How to read and modify Registry Settings from QTP?
  1. […] one of my previous post, I posted about how to read and modify the Registry Settings using VBScript/QTP. But, this […]

  2. […] We can achieve this Automatically (doing this automatically keeps you headache free to do setting on every machine) by doing some Registry Tweaking as explained in one of my previous article. […]

  3. […] I have already talked about How to read/modify and create Registry Settings in previous posts, today I will be talking about how to delete […]

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Blog Stats
  • 168,130 hits

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 796 other followers

%d bloggers like this: