Can QTP work with the Windows Registry at all?
Question ID: 104834
0
0

I know this sounds a little strange, but is there any way to have QuickTest read values stored in the registry at all? I would like to be able to validate an installation routine via automation and need to check that information was written correctly to the registry.

Marked as spam
Posted by (Questions: 227, Answers: 22)
Asked on February 1, 2013 3:07 am
170 views
Answers (1)
2
Private answer

In the Windows Scripting Shell (which QTP can use with VBScript), you have a few methods for reading and writing to the Windows Registry. You need to be very careful with these (especially the writing) as you could mess your test machine up if you don't know what you are doing!

First, understand that there are restrictions on the syntax of the registry root key names. They must be the following:

HKEY_CURRENT_USER or HKCU
HKEY_LOCAL_MACHINE or HKLM
HKEY_CLASSES_ROOT or HKCR
HKEY_USERS (same)
HKEY_CURRENT_CONFIG (same)

The following VBScript example writes a key and value pair into the registry, reads and displays key content, and then removes them from the registry.

'Instantiate the Wscript Shell object
Set WshShell = WScript.CreateObject(''WScript.Shell'')

'How to write to the registry
WshShell.RegWrite ''HKCUDemoQTPKey'', 1 ,''REG_DWORD''

WshShell.RegWrite ''HKCUDemoQTPKeyMyValue'', ''This Is QTP Doing This!''

'Read a registry key and print the value to the QTP Print Dialog

Print WshShell.RegRead(''HKCUDemoQTPKeyMyValue'')
Print WshShell.RegRead(''HKCUDemoQTPKey'')

'Delete the registry key/value
WshShell.RegDelete ''HKCUDemoQTPKeyMyValue''
WshShell.RegDelete ''HKCUDemoQTPKey''

'Cleanup
Set WshShell = Nothing

Marked as spam
Posted by (Questions: 2, Answers: 477)
Answered on February 1, 2013 3:08 am
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top