27 Dec 2012

WScript Programs



How to popup a message with some wait

Set WshShell=CreateObject("WScript.Shell")

WshShell.Popup Welcome to QTP, 5, "Title"

How to get the current UserName of logged in

Set WshNetwork=CreateObject("WScript.Network")

userName = WshNetwork.username

Set WshShell=CreateObject("WScript.Shell")

WshShell.Popup userName, 50, "userName"

How to send keyboard inputs to application

Set WshShell=CreateObject("WScript.Shell")

WshShell.SendKeys "QuickTest Professional"

How to get the value of the system environment variable

Set WshShell=CreateObject("WScript.Shell")

Set WshSysEnv=WshShell.Environment("SYSTEM")

WScript.Echo WshSysEnv("NUMBER_ OF_PROCESSORS" )

How to write and read registry

Set WshShell = CreateObject( "WScript. Shell")

WshShell.RegWrite "HKCU\Software\ ACME\FortuneTell er\", 1, "REG_BINARY"

WshShell.RegWrite "HKCU\Software\ ACME\FortuneTell er\MindReader" , "Goocher!", "REG_SZ"

bKey = WshShell.RegRead( "HKCU\Software\ ACME\FortuneTell er\")

msgbox WshShell.RegRead( "HKCU\Software\ ACME\FortuneTell er\MindReader" )

How to execute DOS commands

Set oShell = CreateObject ("Wscript.shell")

oShell.run "cmd /K CD C:\ & Dir"

No comments:

Post a Comment