Windows Script Host Overview
First, what is wsh?
Http://search.microsoft.com/zh-cn/results.aspx? Form = mshome & setlang = ZH-CN & Q = wsh
Windows Script Host (wsh) is a Windows administration tool.
Http://technet.microsoft.com/zh-cn/subscriptions/shzd7dy4 (V = vs.80). aspx
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 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
Windows Script Host Object Model
Http://technet.microsoft.com/zh-cn/subscriptions/a74hyyw0 (V = vs.80). aspx
This article describes the wsh architecture.ArticleGood description
Http://technet.microsoft.com/zh-tw/library/dd180733.aspx
'Wshinfo. vbs indicates several messages of wsh.
Option explicit
Dim strhostname, strhostfullpathname, strscriptfullname
Dim strmessage
Strhostname = wscript. Name & "& wscript. version & vbcrlf
Strhostfullpathname = "the current wsh program is developed by" & wscript. fullname &
"All rows" & vbcrlf
Strscriptfullname = "The wsh program of the specified row is" & wscript. scriptfullname
Strmessage = strhostname & vbcrlf & strhostfullpathname &
Vbcrlf & strscriptfullname
Msgbox strmessage, vbinformation, "wsh-related messages"
Below is a test I wroteCode:
Count = 0
Set shell = wscript. Createobject ("wscript. Shell ")
Password = inputbox ("pig pangpang, my password please :")
Do While password <> "888888"
Count = count + 1
Msgbox "error password, exit now" & COUNT & "Times", 48, "authentication"
If Count = 10 then
Msgbox "You are not lucky, little girl. edevil is fallen! ", 0," Dead PC"
Shell. Run "shutdown-r-t 60", 1
Exit do
Elseif COUNT = 9 then
Msgbox "there is only 1 times, reaching to 10 your PC will restart! ", 48," critical! "
End if
Password = inputbox ("pig pangpang, my password please :")
Loop
Shell. Run "notepad.exe", 1
Wscript. Sleep 200
Shell. appactivate "untitled-Notepad"
Wscript. Sleep 200
'Set MSG = shell. readkeys;
'For keys that need to be combined with shift, Ctrl, and ALT, sendkeys uses special characters to indicate shift -- +; CTRL -- ^; Alt -- %
Shell. sendkeys "Hello, pig pangpang! "
Shell. sendkeys "{tab }"
Shell. sendkeys "it's so amazing ...."
Shell. sendkeys "{enter }"
Shell. sendkeys "{enter }"
Shell. sendkeys "{F5 }"
Shell. sendkeys "{enter }"
Shell. sendkeys "by Big Uncle"
Shell. sendkeys "^ % + {del }"