SlideShare a Scribd company logo
Visit
     www.ramupalanki.com



               Windows Script Host
Microsoft currently offers three hosts for running scripting language
code. They are:

Internet Explorer (IE)- for running client side scripts in the Web

Internet Information Server (IIS) -for running Server side scripts

Windows Script Host (WSH)- for running scripts on windows
desktop and from the Command promt

WSH (Windows Script Host)

It is Micro Soft Windows Administration Tool to run scripts

WSH is a language-independent scripting host for Windows Script
compatible scripting engines. It allows us to run scripts from both the
Windows desktop and the command prompt

WSH Provides hosting environment for running the Scripts. It has 2
built-in script engines

i) VBScript (extension .vbs)
ii) Jscript (extension .js)

If we want run any other scripts like Perl or Python, we have to install
those script engines.

WSH provides runtime objects to allow our script code to interact with
the local Computer environment.



                                                                           1
WSF (Windows Script File) is an XML file format that allows us to
define scripting jobs.

Two WSH commands, cscript.exe and wscript.exe, are provided to run
scripts with and without a command window.

Remote WSH
It is a new technology available in WSH 5.6 Version, It provides a
facility to run scripts on remote machines.

Windows Script Host Tasks
i) Accessing Networks
ii) Creating Automated Login Script and Logout Script
iii) Driving Applications
iv) Manipulating System Registry
v) Running Scripts Remotely
Etc…


        Shell Scripting Examples
 1) How to display a message with some wait time?
 Dim WshShell
Set WshShell = CreateObject( "WScript.Shell")
WshShell.Popup "Tester", 5, "QTP Training"

2) How to run DOS commands using windows shell script?
 Dim objShell
Set objShell = CreateObject ("WSCript.shell" )
objShell.run "cmd /K CD C:&Dir"

3) How to display Current User Name?
Dim objNetwork, objShell
Set objNetwork = CreateObject( "WScript.Network")
Current_User = objNetwork.username
Set objShell = CreateObject( "WScript.Shell")
objShell.Popup Current_User , 5, " User Name "

4) How to send keyboard inputs?
 set oShell = CreateObject( "WScript.Shell")
oShell.SendKeys "Tester"




                                                                     2
5) How to get Local Computer Information?

Set objComputer = CreateObject("Shell.LocalMachine")

Wscript.Echo "Computer name: " & objComputer.MachineName
Wscript.Echo "Shutdown allowed: " & objComputer.IsShutdownAllowed
Wscript.Echo "Friendly UI enabled: " &
objComputer.IsFriendlyUIEnabled
Wscript.Echo "Guest access mode: " &
objComputer.IsGuestAccessMode
Wscript.Echo "Guest account enabled: " & _
  objComputer.IsGuestEnabled(0)
Wscript.Echo "Multiple users enabled: " & _
  objComputer.IsMultipleUsersEnabled
Wscript.Echo "Offline files enabled: " & _
  objComputer.IsOfflineFilesEnabled
Wscript.Echo "Remote connections enabled: " & _
  objComputer.IsRemoteConnectionsEnabled
Wscript.Echo "Undock enabled: " & objComputer.IsUndockEnabled


Note: Run the above script as vbscript file(.vbs), It may not
work in QTP Test Pane.
----------------------------------------------------------------


We can run VBScript code file directly. But WSH also supports an XML
file format called .WSF (Windows Script File).

WSF file offers an XML structure to define script jobs and group jobs
into a package

<package>

  <job id="VBScriptJob">
    <script language="VBScript">
      WScript.Echo "Hello Tester! - VBScriptJob"
    </script>
  </job>

  <job id="JScriptJob">
    <script language="JScript">
      WScript.Echo("Hello Tester! - JScriptJob");
    </script>


                                                                        3
</job>

</package>




             4

More Related Content

PPT
New kid on the block node.js
Joel Divekar
 
DOCX
Cscript exe
ssuser1eca7d
 
PPTX
33 meta
SatyakiDas12
 
ODP
Mule ESB : ssh connector
AnilKumar Etagowni
 
ZIP
IronRuby
Alex Moore
 
PDF
Beyond Golden Containers: Complementing Docker with Puppet
lutter
 
PDF
Node.js et NPM: de la récupération de dépendances à la publication de paquets
Frank Rousseau
 
New kid on the block node.js
Joel Divekar
 
Cscript exe
ssuser1eca7d
 
33 meta
SatyakiDas12
 
Mule ESB : ssh connector
AnilKumar Etagowni
 
IronRuby
Alex Moore
 
Beyond Golden Containers: Complementing Docker with Puppet
lutter
 
Node.js et NPM: de la récupération de dépendances à la publication de paquets
Frank Rousseau
 

What's hot (20)

PPTX
Cross-Platform Desktop Apps with JavaScript
Blagoja Evkoski
 
DOC
Tên hàm
huynhthanhson
 
PDF
Introduction to php web programming - sessions and cookies
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Cookie and session
Aashish Ghale
 
PDF
Development box at Startit Tech Meetup
Startit
 
PPTX
PHP Cookies and Sessions
Nisa Soomro
 
PDF
ExtJS勉強会@名古屋
Tsuyoshi Yamamoto
 
PDF
Chrome拡張開発者のためのFirefox拡張開発
swdyh
 
PPT
PHP - Introduction to PHP Cookies and Sessions
Vibrant Technologies & Computers
 
PPT
PHP - Getting good with cookies
Firdaus Adib
 
PPTX
Session and Cookies
Kamal Acharya
 
PPTX
Top 28 programming language with hello world for artificial intelligence
AL- AMIN
 
PPTX
Automated Testing
Speed FC
 
PDF
IPython from 30,000 feet
takluyver
 
ODP
Session Management & Cookies In Php
Harit Kothari
 
PDF
MongoDB shell games: Here be dragons .. and JavaScript!
Stennie Steneker
 
PPT
Php ssession - cookies -introduction
Programmer Blog
 
PDF
MongoDB + node.js で作るソーシャルゲーム
Suguru Namura
 
PPTX
Sessions in php
Mudasir Syed
 
Cross-Platform Desktop Apps with JavaScript
Blagoja Evkoski
 
Tên hàm
huynhthanhson
 
Introduction to php web programming - sessions and cookies
baabtra.com - No. 1 supplier of quality freshers
 
Cookie and session
Aashish Ghale
 
Development box at Startit Tech Meetup
Startit
 
PHP Cookies and Sessions
Nisa Soomro
 
ExtJS勉強会@名古屋
Tsuyoshi Yamamoto
 
Chrome拡張開発者のためのFirefox拡張開発
swdyh
 
PHP - Introduction to PHP Cookies and Sessions
Vibrant Technologies & Computers
 
PHP - Getting good with cookies
Firdaus Adib
 
Session and Cookies
Kamal Acharya
 
Top 28 programming language with hello world for artificial intelligence
AL- AMIN
 
Automated Testing
Speed FC
 
IPython from 30,000 feet
takluyver
 
Session Management & Cookies In Php
Harit Kothari
 
MongoDB shell games: Here be dragons .. and JavaScript!
Stennie Steneker
 
Php ssession - cookies -introduction
Programmer Blog
 
MongoDB + node.js で作るソーシャルゲーム
Suguru Namura
 
Sessions in php
Mudasir Syed
 
Ad

Viewers also liked (7)

PPT
Webquest[1]
jdp59
 
PPTX
H(app)athon Project Host Toolkit
John C. Havens
 
DOCX
Debate script
guest5a2e576
 
PPTX
Lecture 1 introduction to debate (fall 2012)
CJMcRae
 
PDF
A public debate on the attainment targets in Flanders
EduSkills OECD
 
PPTX
Example script for moderator
Ade Johan
 
DOC
Emcee Script
Sini.sinta Kita
 
Webquest[1]
jdp59
 
H(app)athon Project Host Toolkit
John C. Havens
 
Debate script
guest5a2e576
 
Lecture 1 introduction to debate (fall 2012)
CJMcRae
 
A public debate on the attainment targets in Flanders
EduSkills OECD
 
Example script for moderator
Ade Johan
 
Emcee Script
Sini.sinta Kita
 
Ad

Similar to Qtp wsh scripts examples (20)

PPTX
Scripting and Automation within the MAX Platform - Mark Petrie
MAXfocus
 
PPTX
Nagios Conference 2011 - Michael Medin - Workshop: Scripting On The Windows Side
Nagios
 
PPTX
Wsv406 Advanced Automation Using Windows Power Shell2.0
jsnover1
 
PPTX
PASS 24HOP Linux Scripting Tips and Tricks
Kellyn Pot'Vin-Gorman
 
PPTX
Introducing PowerShell 3.0
Jan Egil Ring
 
PPTX
Shell & Shell Script
Amit Ghosh
 
PPTX
Shell & Shell Script
Amit Ghosh
 
PPTX
Windows Remote Management - EN
Kirill Nikolaev
 
PPTX
Powershell Tech Ed2009
rsnarayanan
 
PPTX
Ordina Accelerator program 2019 - Linux
Bert Koorengevel
 
PDF
Batch file-programming
jamilur
 
PDF
Batch file programming
alan moreno
 
PPTX
PowerShellForDBDevelopers
Bryan Cafferky
 
PPTX
Powering up on PowerShell - BSides Greenville 2019
Fernando Tomlinson, CISSP, MBA
 
PPTX
Scripting as a Second Language
Rob Dunn
 
PPTX
Getting Started With PowerShell Scripting
Ravikanth Chaganti
 
PPT
Wsus sample scripts
Concentrated Technology
 
PPTX
Introduction to scripts
sana mateen
 
PPTX
Powering up on power shell avengercon - 2018
Fernando Tomlinson, CISSP, MBA
 
PDF
linux_Commads
tastedone
 
Scripting and Automation within the MAX Platform - Mark Petrie
MAXfocus
 
Nagios Conference 2011 - Michael Medin - Workshop: Scripting On The Windows Side
Nagios
 
Wsv406 Advanced Automation Using Windows Power Shell2.0
jsnover1
 
PASS 24HOP Linux Scripting Tips and Tricks
Kellyn Pot'Vin-Gorman
 
Introducing PowerShell 3.0
Jan Egil Ring
 
Shell & Shell Script
Amit Ghosh
 
Shell & Shell Script
Amit Ghosh
 
Windows Remote Management - EN
Kirill Nikolaev
 
Powershell Tech Ed2009
rsnarayanan
 
Ordina Accelerator program 2019 - Linux
Bert Koorengevel
 
Batch file-programming
jamilur
 
Batch file programming
alan moreno
 
PowerShellForDBDevelopers
Bryan Cafferky
 
Powering up on PowerShell - BSides Greenville 2019
Fernando Tomlinson, CISSP, MBA
 
Scripting as a Second Language
Rob Dunn
 
Getting Started With PowerShell Scripting
Ravikanth Chaganti
 
Wsus sample scripts
Concentrated Technology
 
Introduction to scripts
sana mateen
 
Powering up on power shell avengercon - 2018
Fernando Tomlinson, CISSP, MBA
 
linux_Commads
tastedone
 

More from Ramu Palanki (20)

DOC
Qtp sample certification questions and answers
Ramu Palanki
 
DOC
Qtp realtime scripts
Ramu Palanki
 
DOC
Qtp questions and answers
Ramu Palanki
 
PPT
Qtp presentation
Ramu Palanki
 
DOC
Qtp material for beginners
Ramu Palanki
 
DOC
Qtp interview questions
Ramu Palanki
 
DOC
Qtp interview questions and answers
Ramu Palanki
 
DOC
Qtp interview questions3
Ramu Palanki
 
DOC
Qtp complete guide for all
Ramu Palanki
 
DOC
Qtp compare two xml files
Ramu Palanki
 
DOC
Qtp change excel cell color with condition
Ramu Palanki
 
DOCX
Qtp certification questions
Ramu Palanki
 
DOCX
Qtp certification questions and tutorial
Ramu Palanki
 
DOCX
Qtp certification questions2
Ramu Palanki
 
DOCX
Qtp best tutorial
Ramu Palanki
 
DOC
Qtp basic stuff
Ramu Palanki
 
DOC
Qtp automation estimation techniques
Ramu Palanki
 
DOC
Qtp 11 new enhacements in
Ramu Palanki
 
DOC
Qtp sample resume
Ramu Palanki
 
DOCX
Qtp passing parameters between actions
Ramu Palanki
 
Qtp sample certification questions and answers
Ramu Palanki
 
Qtp realtime scripts
Ramu Palanki
 
Qtp questions and answers
Ramu Palanki
 
Qtp presentation
Ramu Palanki
 
Qtp material for beginners
Ramu Palanki
 
Qtp interview questions
Ramu Palanki
 
Qtp interview questions and answers
Ramu Palanki
 
Qtp interview questions3
Ramu Palanki
 
Qtp complete guide for all
Ramu Palanki
 
Qtp compare two xml files
Ramu Palanki
 
Qtp change excel cell color with condition
Ramu Palanki
 
Qtp certification questions
Ramu Palanki
 
Qtp certification questions and tutorial
Ramu Palanki
 
Qtp certification questions2
Ramu Palanki
 
Qtp best tutorial
Ramu Palanki
 
Qtp basic stuff
Ramu Palanki
 
Qtp automation estimation techniques
Ramu Palanki
 
Qtp 11 new enhacements in
Ramu Palanki
 
Qtp sample resume
Ramu Palanki
 
Qtp passing parameters between actions
Ramu Palanki
 

Qtp wsh scripts examples

  • 1. Visit www.ramupalanki.com Windows Script Host Microsoft currently offers three hosts for running scripting language code. They are: Internet Explorer (IE)- for running client side scripts in the Web Internet Information Server (IIS) -for running Server side scripts Windows Script Host (WSH)- for running scripts on windows desktop and from the Command promt WSH (Windows Script Host) It is Micro Soft Windows Administration Tool to run scripts WSH is a language-independent scripting host for Windows Script compatible scripting engines. It allows us to run scripts from both the Windows desktop and the command prompt WSH Provides hosting environment for running the Scripts. It has 2 built-in script engines i) VBScript (extension .vbs) ii) Jscript (extension .js) If we want run any other scripts like Perl or Python, we have to install those script engines. WSH provides runtime objects to allow our script code to interact with the local Computer environment. 1
  • 2. WSF (Windows Script File) is an XML file format that allows us to define scripting jobs. Two WSH commands, cscript.exe and wscript.exe, are provided to run scripts with and without a command window. Remote WSH It is a new technology available in WSH 5.6 Version, It provides a facility to run scripts on remote machines. Windows Script Host Tasks i) Accessing Networks ii) Creating Automated Login Script and Logout Script iii) Driving Applications iv) Manipulating System Registry v) Running Scripts Remotely Etc… Shell Scripting Examples 1) How to display a message with some wait time? Dim WshShell Set WshShell = CreateObject( "WScript.Shell") WshShell.Popup "Tester", 5, "QTP Training" 2) How to run DOS commands using windows shell script? Dim objShell Set objShell = CreateObject ("WSCript.shell" ) objShell.run "cmd /K CD C:&Dir" 3) How to display Current User Name? Dim objNetwork, objShell Set objNetwork = CreateObject( "WScript.Network") Current_User = objNetwork.username Set objShell = CreateObject( "WScript.Shell") objShell.Popup Current_User , 5, " User Name " 4) How to send keyboard inputs? set oShell = CreateObject( "WScript.Shell") oShell.SendKeys "Tester" 2
  • 3. 5) How to get Local Computer Information? Set objComputer = CreateObject("Shell.LocalMachine") Wscript.Echo "Computer name: " & objComputer.MachineName Wscript.Echo "Shutdown allowed: " & objComputer.IsShutdownAllowed Wscript.Echo "Friendly UI enabled: " & objComputer.IsFriendlyUIEnabled Wscript.Echo "Guest access mode: " & objComputer.IsGuestAccessMode Wscript.Echo "Guest account enabled: " & _ objComputer.IsGuestEnabled(0) Wscript.Echo "Multiple users enabled: " & _ objComputer.IsMultipleUsersEnabled Wscript.Echo "Offline files enabled: " & _ objComputer.IsOfflineFilesEnabled Wscript.Echo "Remote connections enabled: " & _ objComputer.IsRemoteConnectionsEnabled Wscript.Echo "Undock enabled: " & objComputer.IsUndockEnabled Note: Run the above script as vbscript file(.vbs), It may not work in QTP Test Pane. ---------------------------------------------------------------- We can run VBScript code file directly. But WSH also supports an XML file format called .WSF (Windows Script File). WSF file offers an XML structure to define script jobs and group jobs into a package <package> <job id="VBScriptJob"> <script language="VBScript"> WScript.Echo "Hello Tester! - VBScriptJob" </script> </job> <job id="JScriptJob"> <script language="JScript"> WScript.Echo("Hello Tester! - JScriptJob"); </script> 3