As mentioned in the QTP help, Windows Script Host (WSH) is a windows administration tool. WSH creates an environment for hosting scripts. That is, when a script arrives at your computer, WSH plays the part of the host. That is it makes objects and services available for the script and provides a set of guidelines within which the script is executed. Among other things, Windows Script Host manages security and invokes the appropriate script engine.
It brings simple, powerful, and flexible scripting to the Windows platform, allowing you to run
scripts from both the Windows desktop and the command prompt.
Windows Script Host is ideal for non - interactive scripting needs, such as logon scripting, administrative scripting and machine automation.
- Print messages to the screen
- Run basic functions such as CreateObject and GetObject
- Map network drives
- Connect to printers
- Retrieve and modify environment variables
- Modify registry keys
- Manipulating the Windows environment
- Running other programs
- Automating logon procedures
- Sending key sequences to an application
Code sample to generate an auto close pop up dialog.
Set objShell = CreateObject("Wscript.Shell")
strMessage = "This is an auto close dialog . .!!"
objShell.popup strMessage, 4, "Shell object pop - up"
Code sample to run an exe file or Window based program.
Set objShell = CreateObject("Wscript.Shell")
objShell.exec ("C:\Program Files\HP\Quicktest Professional\Samples\Flight\app\flight4a.exe")
objshell.Run "H:\WSH_QTP\test_1.vbs"
objShell.exec ("calc")
But WSH does not run the below statement, giving an error “not a WIN32 application”
objShell.Exec "H:\WSH_&_QTP\test1.vbs"
As per my understanding, RUN is used to run windows specific applications and EXEC to execute a statement.
Code sample to send keyboard keys.
Set objShell = CreateObject("Wscript.Shell")
objShell.SendKeys ("{ENTER}")
objShell.SendKeys ("%+{F4}")
------------------------------------------------------------------------------------------------------------
Cheers . . !!
# Hims (:
No comments:
Post a Comment