SlideShare a Scribd company logo
1 of 4
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

What's hot

Cross-Platform Desktop Apps with JavaScript
Cross-Platform Desktop Apps with JavaScriptCross-Platform Desktop Apps with JavaScript
Cross-Platform Desktop Apps with JavaScriptBlagoja Evkoski
 
Development box at Startit Tech Meetup
Development box at Startit Tech MeetupDevelopment box at Startit Tech Meetup
Development box at Startit Tech MeetupStartit
 
PHP Cookies and Sessions
PHP Cookies and SessionsPHP Cookies and Sessions
PHP Cookies and SessionsNisa Soomro
 
Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発swdyh
 
PHP - Getting good with cookies
PHP - Getting good with cookiesPHP - Getting good with cookies
PHP - Getting good with cookiesFirdaus Adib
 
Top 28 programming language with hello world for artificial intelligence
Top 28 programming language with  hello world for artificial intelligenceTop 28 programming language with  hello world for artificial intelligence
Top 28 programming language with hello world for artificial intelligenceAL- AMIN
 
Automated Testing
Automated TestingAutomated Testing
Automated TestingSpeed FC
 
IPython from 30,000 feet
IPython from 30,000 feetIPython from 30,000 feet
IPython from 30,000 feettakluyver
 
Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In PhpHarit Kothari
 
MongoDB shell games: Here be dragons .. and JavaScript!
MongoDB shell games: Here be dragons .. and JavaScript!MongoDB shell games: Here be dragons .. and JavaScript!
MongoDB shell games: Here be dragons .. and JavaScript!Stennie Steneker
 
Php ssession - cookies -introduction
Php ssession - cookies -introductionPhp ssession - cookies -introduction
Php ssession - cookies -introductionProgrammer Blog
 
MongoDB + node.js で作るソーシャルゲーム
MongoDB + node.js で作るソーシャルゲームMongoDB + node.js で作るソーシャルゲーム
MongoDB + node.js で作るソーシャルゲームSuguru Namura
 

What's hot (20)

Cross-Platform Desktop Apps with JavaScript
Cross-Platform Desktop Apps with JavaScriptCross-Platform Desktop Apps with JavaScript
Cross-Platform Desktop Apps with JavaScript
 
Tên hàm
Tên hàmTên hàm
Tên hàm
 
Introduction to php web programming - sessions and cookies
Introduction to php   web programming - sessions and cookiesIntroduction to php   web programming - sessions and cookies
Introduction to php web programming - sessions and cookies
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Cookie and session
Cookie and sessionCookie and session
Cookie and session
 
Development box at Startit Tech Meetup
Development box at Startit Tech MeetupDevelopment box at Startit Tech Meetup
Development box at Startit Tech Meetup
 
PHP Cookies and Sessions
PHP Cookies and SessionsPHP Cookies and Sessions
PHP Cookies and Sessions
 
ExtJS勉強会@名古屋
ExtJS勉強会@名古屋ExtJS勉強会@名古屋
ExtJS勉強会@名古屋
 
Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発Chrome拡張開発者のためのFirefox拡張開発
Chrome拡張開発者のためのFirefox拡張開発
 
PHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and SessionsPHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and Sessions
 
PHP - Getting good with cookies
PHP - Getting good with cookiesPHP - Getting good with cookies
PHP - Getting good with cookies
 
Session and Cookies
Session and CookiesSession and Cookies
Session and Cookies
 
Top 28 programming language with hello world for artificial intelligence
Top 28 programming language with  hello world for artificial intelligenceTop 28 programming language with  hello world for artificial intelligence
Top 28 programming language with hello world for artificial intelligence
 
Automated Testing
Automated TestingAutomated Testing
Automated Testing
 
IPython from 30,000 feet
IPython from 30,000 feetIPython from 30,000 feet
IPython from 30,000 feet
 
Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In Php
 
MongoDB shell games: Here be dragons .. and JavaScript!
MongoDB shell games: Here be dragons .. and JavaScript!MongoDB shell games: Here be dragons .. and JavaScript!
MongoDB shell games: Here be dragons .. and JavaScript!
 
Php ssession - cookies -introduction
Php ssession - cookies -introductionPhp ssession - cookies -introduction
Php ssession - cookies -introduction
 
MongoDB + node.js で作るソーシャルゲーム
MongoDB + node.js で作るソーシャルゲームMongoDB + node.js で作るソーシャルゲーム
MongoDB + node.js で作るソーシャルゲーム
 
Sessions in php
Sessions in php Sessions in php
Sessions in php
 

Viewers also liked

Webquest[1]
Webquest[1]Webquest[1]
Webquest[1]jdp59
 
H(app)athon Project Host Toolkit
H(app)athon Project Host ToolkitH(app)athon Project Host Toolkit
H(app)athon Project Host ToolkitJohn C. Havens
 
Lecture 1 introduction to debate (fall 2012)
Lecture 1 introduction to debate (fall 2012)Lecture 1 introduction to debate (fall 2012)
Lecture 1 introduction to debate (fall 2012)CJMcRae
 
A public debate on the attainment targets in Flanders
A public debate on the attainment targets in FlandersA public debate on the attainment targets in Flanders
A public debate on the attainment targets in FlandersEduSkills OECD
 
Example script for moderator
Example script for moderatorExample script for moderator
Example script for moderatorAde Johan
 

Viewers also liked (7)

Webquest[1]
Webquest[1]Webquest[1]
Webquest[1]
 
H(app)athon Project Host Toolkit
H(app)athon Project Host ToolkitH(app)athon Project Host Toolkit
H(app)athon Project Host Toolkit
 
Debate script
Debate scriptDebate script
Debate script
 
Lecture 1 introduction to debate (fall 2012)
Lecture 1 introduction to debate (fall 2012)Lecture 1 introduction to debate (fall 2012)
Lecture 1 introduction to debate (fall 2012)
 
A public debate on the attainment targets in Flanders
A public debate on the attainment targets in FlandersA public debate on the attainment targets in Flanders
A public debate on the attainment targets in Flanders
 
Example script for moderator
Example script for moderatorExample script for moderator
Example script for moderator
 
Emcee Script
Emcee ScriptEmcee Script
Emcee Script
 

Similar to Windows Script Host (WSH) Overview

Virtual machines and containers
Virtual machines and containersVirtual machines and containers
Virtual machines and containersPatrick Pierson
 
Scripting as a Second Language
Scripting as a Second LanguageScripting as a Second Language
Scripting as a Second LanguageRob Dunn
 
Client side scripting using Javascript
Client side scripting using JavascriptClient side scripting using Javascript
Client side scripting using JavascriptBansari Shah
 
Open Source Virtualization Hacks
Open Source Virtualization HacksOpen Source Virtualization Hacks
Open Source Virtualization HacksNiel Bornstein
 
Making clouds: turning opennebula into a product
Making clouds: turning opennebula into a productMaking clouds: turning opennebula into a product
Making clouds: turning opennebula into a productCarlo Daffara
 
Making Clouds: Turning OpenNebula into a Product
Making Clouds: Turning OpenNebula into a ProductMaking Clouds: Turning OpenNebula into a Product
Making Clouds: Turning OpenNebula into a ProductNETWAYS
 
OpenNebulaConf 2013 - Making Clouds: Turning OpenNebula into a Product by Car...
OpenNebulaConf 2013 - Making Clouds: Turning OpenNebula into a Product by Car...OpenNebulaConf 2013 - Making Clouds: Turning OpenNebula into a Product by Car...
OpenNebulaConf 2013 - Making Clouds: Turning OpenNebula into a Product by Car...OpenNebula Project
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010Tim Clark
 
Native client
Native clientNative client
Native clientzyc901016
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101Rami Sayar
 
Post exploitation using powershell
Post exploitation using powershellPost exploitation using powershell
Post exploitation using powershellMihir Shah
 
PowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersPowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersBoulos Dib
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami SayarFITC
 

Similar to Windows Script Host (WSH) Overview (20)

Virtual machines and containers
Virtual machines and containersVirtual machines and containers
Virtual machines and containers
 
Node36
Node36Node36
Node36
 
Scripting as a Second Language
Scripting as a Second LanguageScripting as a Second Language
Scripting as a Second Language
 
Client side scripting using Javascript
Client side scripting using JavascriptClient side scripting using Javascript
Client side scripting using Javascript
 
Open Source Virtualization Hacks
Open Source Virtualization HacksOpen Source Virtualization Hacks
Open Source Virtualization Hacks
 
Proposal
ProposalProposal
Proposal
 
Making clouds: turning opennebula into a product
Making clouds: turning opennebula into a productMaking clouds: turning opennebula into a product
Making clouds: turning opennebula into a product
 
Making Clouds: Turning OpenNebula into a Product
Making Clouds: Turning OpenNebula into a ProductMaking Clouds: Turning OpenNebula into a Product
Making Clouds: Turning OpenNebula into a Product
 
OpenNebulaConf 2013 - Making Clouds: Turning OpenNebula into a Product by Car...
OpenNebulaConf 2013 - Making Clouds: Turning OpenNebula into a Product by Car...OpenNebulaConf 2013 - Making Clouds: Turning OpenNebula into a Product by Car...
OpenNebulaConf 2013 - Making Clouds: Turning OpenNebula into a Product by Car...
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010
 
Building Client-Side Attacks with HTML5 Features
Building Client-Side Attacks with HTML5 FeaturesBuilding Client-Side Attacks with HTML5 Features
Building Client-Side Attacks with HTML5 Features
 
SQL Server on Linux
SQL Server on LinuxSQL Server on Linux
SQL Server on Linux
 
Dynamic virtual evironments
Dynamic virtual evironmentsDynamic virtual evironments
Dynamic virtual evironments
 
Native client
Native clientNative client
Native client
 
PowerShell Remoting
PowerShell RemotingPowerShell Remoting
PowerShell Remoting
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
 
Post exploitation using powershell
Post exploitation using powershellPost exploitation using powershell
Post exploitation using powershell
 
PowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersPowerShell for SharePoint Developers
PowerShell for SharePoint Developers
 
aws.ppt
aws.pptaws.ppt
aws.ppt
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami Sayar
 

More from Ramu Palanki

Qtp sample certification questions and answers
Qtp sample certification questions and answersQtp sample certification questions and answers
Qtp sample certification questions and answersRamu Palanki
 
Qtp realtime scripts
Qtp realtime scriptsQtp realtime scripts
Qtp realtime scriptsRamu Palanki
 
Qtp questions and answers
Qtp questions and answersQtp questions and answers
Qtp questions and answersRamu Palanki
 
Qtp material for beginners
Qtp material for beginnersQtp material for beginners
Qtp material for beginnersRamu Palanki
 
Qtp interview questions
Qtp interview questionsQtp interview questions
Qtp interview questionsRamu Palanki
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answersRamu Palanki
 
Qtp interview questions3
Qtp interview questions3Qtp interview questions3
Qtp interview questions3Ramu Palanki
 
Qtp complete guide for all
Qtp complete guide for allQtp complete guide for all
Qtp complete guide for allRamu Palanki
 
Qtp compare two xml files
Qtp compare two xml filesQtp compare two xml files
Qtp compare two xml filesRamu Palanki
 
Qtp change excel cell color with condition
Qtp change excel cell color with conditionQtp change excel cell color with condition
Qtp change excel cell color with conditionRamu Palanki
 
Qtp certification questions
Qtp certification questionsQtp certification questions
Qtp certification questionsRamu Palanki
 
Qtp certification questions and tutorial
Qtp certification questions and tutorialQtp certification questions and tutorial
Qtp certification questions and tutorialRamu Palanki
 
Qtp certification questions2
Qtp certification questions2Qtp certification questions2
Qtp certification questions2Ramu Palanki
 
Qtp automation estimation techniques
Qtp automation estimation techniquesQtp automation estimation techniques
Qtp automation estimation techniquesRamu Palanki
 
Qtp 11 new enhacements in
Qtp 11 new enhacements inQtp 11 new enhacements in
Qtp 11 new enhacements inRamu Palanki
 
Qtp passing parameters between actions
Qtp passing parameters between actionsQtp passing parameters between actions
Qtp passing parameters between actionsRamu Palanki
 

More from Ramu Palanki (20)

Qtp sample certification questions and answers
Qtp sample certification questions and answersQtp sample certification questions and answers
Qtp sample certification questions and answers
 
Qtp realtime scripts
Qtp realtime scriptsQtp realtime scripts
Qtp realtime scripts
 
Qtp questions and answers
Qtp questions and answersQtp questions and answers
Qtp questions and answers
 
Qtp presentation
Qtp presentationQtp presentation
Qtp presentation
 
Qtp material for beginners
Qtp material for beginnersQtp material for beginners
Qtp material for beginners
 
Qtp interview questions
Qtp interview questionsQtp interview questions
Qtp interview questions
 
Qtp interview questions and answers
Qtp interview questions and answersQtp interview questions and answers
Qtp interview questions and answers
 
Qtp interview questions3
Qtp interview questions3Qtp interview questions3
Qtp interview questions3
 
Qtp complete guide for all
Qtp complete guide for allQtp complete guide for all
Qtp complete guide for all
 
Qtp compare two xml files
Qtp compare two xml filesQtp compare two xml files
Qtp compare two xml files
 
Qtp change excel cell color with condition
Qtp change excel cell color with conditionQtp change excel cell color with condition
Qtp change excel cell color with condition
 
Qtp certification questions
Qtp certification questionsQtp certification questions
Qtp certification questions
 
Qtp certification questions and tutorial
Qtp certification questions and tutorialQtp certification questions and tutorial
Qtp certification questions and tutorial
 
Qtp certification questions2
Qtp certification questions2Qtp certification questions2
Qtp certification questions2
 
Qtp best tutorial
Qtp best tutorialQtp best tutorial
Qtp best tutorial
 
Qtp basic stuff
Qtp basic stuffQtp basic stuff
Qtp basic stuff
 
Qtp automation estimation techniques
Qtp automation estimation techniquesQtp automation estimation techniques
Qtp automation estimation techniques
 
Qtp 11 new enhacements in
Qtp 11 new enhacements inQtp 11 new enhacements in
Qtp 11 new enhacements in
 
Qtp sample resume
Qtp sample resumeQtp sample resume
Qtp sample resume
 
Qtp passing parameters between actions
Qtp passing parameters between actionsQtp passing parameters between actions
Qtp passing parameters between actions
 

Windows Script Host (WSH) Overview

  • 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