Getting Started With WSH 5.6 - Are you Ready?
(Page 2 of 7 )
Ok, before we start, I'll presume that you know and understand what a script is. If you do, then skip to the next section. If you don't, then keep reading.
A script is a set of instructions. The computer executes the instructions, then returns some sort of value: a number, string, list, or another data type. As far as the WSH goes, it might look something like this:
<? XML version="1.0" ? >
<!-- Filename: Hello.wsf-->
<job>
<script language="VBScript">
WScript.Echo "Hello, from you VBScript friends! Please press OK."
</script>
<script language="JScript">
WScript.Echo ("Hey, this is JScript. Can you click OK again? I can't quite reach it.") ;
</script>
</job>
I say "might" because WSH is really a language-independent, object-model independent tool. At first, most of the stuff you'll be looking at will probably look like this:
'This will tell you the Username, Domain, and Computer Name
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
Wscript.echo WshNetwork.Username
Wscript.echo WshNetwork.UserDomain
Wscript.echo WshNetwork.ComputerName
Just a tad different, wouldn't you agree?
If you're sure that you have at least WSH 2.0 installed, then go ahead and copy and paste these into Notepad, saving them as example1.wsh and example2.vbs (respectively). Double click on them and see how they work. If you're not totally sure that you have at least version 2.0 installed, keep reading before you do anything else. Don't worry about whether you know those commands mean right now. By the time you finish this you'll know at least what they're doing and how. All you should care about right now is that you know what a script is. Hazzah!
Next: Heeeeeeeere's Your Host... >>
More Windows Scripting Articles
More By Norbert Cartagena