WSH

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 — 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.

WSH is language-independent for WSH-compliant scripting engines. 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 noninteractive scripting needs, such as logon scripting, administrative scripting, and machine automation.

WSH Objects and Services
Windows Script Host provides several objects for direct manipulation of script execution, as well as helper functions for other actions. Using these objects and services, you can accomplish tasks such as the following:
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
Wscript :
  • Set and retrieve command line arguments
  • Determine the name of the script file
  • Determine the host file name (wscript.exe or cscript.exe)
  • Determine the host version information
  • Create, connect to, and disconnect from COM objects
  • Sink events
  • Stop a script's execution programmatically
  • Output information to the default output device (for example, a dialog box or the command line)
WshArguments
  • Access the entire set of command-line arguments
WshNamed
  • Access the set of named command-line arguments
WshUnnamed
  • Access the set of unnamed command-line arguments
WshNetwork
  • Connect to and disconnect from network shares and network printers
  • Map and unmap network shares
  • Access information about the currently logged-on user
WshController
  • Create a remote script process using the Controller method CreateScript()
WshRemote
  • Remotely administer computer systems on a computer network
  • Programmatically manipulate other programs/scripts
WshRemote
  • Error Access the error information available when a remote script (a WshRemote object) terminates as a result of a script error
WshShell
  • Run a program locally
  • Manipulate the contents of the registry
  • Create a shortcut
  • Access a system folder Manipulate environment variables (such as WINDIR, PATH, or PROMPT)
WshShortcut
  • Programmatically create a shortcut
WshSpecialfolders
  • Access any of the Windows Special Folders
WshURLShortcut
  • Programmatically create a shortcut to an Internet resource
WshEnvironment
  • Access any of the environment variables (such as WINDIR, PATH, or PROMPT) WshScriptExec
  • Determine status and error information about a script run with Exec()
  • Access the StdIn, StdOut, and StdErr channels

''''''Display the username, domain, computername

===============================================
Set obj=CreateObject("WScript.NetWork")

str="User Name is " & obj.UserName str=str&"Computer Name is " & obj.ComputerNamestr=str&"Domain Name is " & obj.UserDomainMsgBox strSet obj=Nothing

==============================================='

'''''Run notepad.exe and send ALT+F4 key which will close nodepad
Set obj=CreateObject("WScript.Shell")

obj.Run "notepad.exe"

wait(5)

obj.SendKeys "%{F4}"
==============================================

set ws = CreateObject("WScript.Shell")

ws.Run "calc"

wait(2)

ws.SendKeys "1{+}"

wait(2)

ws.SendKeys "2"

wait(2)

ws.SendKeys "~"

wait(2)

ws.SendKeys "*3"

wait(2)

ws.SendKeys "~"

Comments