Facebook

Course Name Start Date Time Duration Registration Link
No Training Programs Scheduled ClickHere to Contact
Please mail To sudhakar@qtpsudhakar.com to Register for any training

Monday, January 23, 2012

WSH Scripting Samples

'***************************************************
'How to popup a message with some wait
'***************************************************
Set WshShell = CreateObject( "WScript.Shell")
WshShell.Popup "message body", 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