Windows Vista 98
![]() Yaesu FTC and FTR Radios/Repeaters Data Mode Cable US $40.64
|
Microsoft has built an incredibly powerful scripting language that can control almost every aspect of the Windows operating system. What I will be discussing here are only the basics that apply mostly to windows XP. Windows scripting has been around since Windows 98 but as the operating systems have progressed the scripting language has as well.
All the tools that we need to created windows scripts are included in windows and the is simply notepad. You can get other editors to use such as Script Editor, Scintilla and SciTE, and many more. But all that you need is Notepad and you are good to go. When you create a scripting file you will create any name you want and you can give it the extension of .VBS (Visual Basic Script).
Lets write out first script, the famous Hello World script, by opening up notepad and simply typing:
wscript.echo "Hello World"
Now simply double click on the file that you have created and you will see a pop up box that will display the text "Hello World" give it a try. This script can also be executed by a command prompt by typing "cscript hello.vbs" from the command prompt.
All good programmers comment their programs so that years from now they can look back at a program they wrote and tell what it is doing based on the comments. A comment is simply text in the program that is only seen by the programmer and never by the person running the program. You can type anything you want in a comment and it will not effect the program in any way. Professional programmers comment on every aspect of their program so that others who read the code can understand what it is doing. To add a comment in a VBS file simply type REM or ' at the beginning of a line and every thing on that line will be a remark and will have no effect on the program. Lets look at our Hello.vbs program and lets add a couple of remarks in the program so that we know what is going on.
' hello.vbs
' This is just your typical Hello World program
wscript.echo "Hello World"
If you happen to type something wrong windows will give you an error telling you that you have done something wrong and will even give you the line that the error is on. Lets mess up our program and see what kind of error we receive.
' hello.vbs
' This is just your typical Hello World program
wscript.echo "Hello World"
wscript.ech "I messed up this line"
Now lets run the program and see what kind of error we get. The first line is executed just fine but we receive a error on the second line:
Script: c:usersmikedesktophello.vbs
Line: 5
Char: 1
Error: Object doesn't support this property or method: 'wscript.ech'
Code: 800A01B6
Source: Microsoft VBScript runtime error
So as you can see from this error that we have a problem on line 5 character 1 of our code. The error Object doesn't support this property or method: 'wscript.ech' usually means that you have a misspelling somewhere. The Code is not really that important to know just the location of the problem and what the "Error" actually says.
As with any programming language VBScript uses variables to hold values and strings. To assign a value to a variable simply use the variable name you would like and then the = sign. One examble would be 'mike = 24' now the variable mike has a value of 24, now lets add this to our Hello World program and show that the variable mike has a value of 24.
' hello.vbs
' This is your typical Hello World program
wscript.echo "Hello World"
mike = 24
jake = 30
diff = jake - mike
wscript.echo "Mike is ", mike
wscript.echo "Jake is ", jake
wscript.echo "The difference between their age is ", diff
As you can see here we assigned the value 24 to the variable mike and we assigned the value of 30 to the variable jake. We were then able to perform and mathmatical operation on the two values to get the difference between them. Then by using the wscript.echo command we were able to display the variables. Lets continue on with variables and lets store a string which is stored as text and we will get input from our user.
' hello.vbs
' This is your typical Hello World program
name = InputBox("What is your name?")
age = InputBox("How old are you?")
wscript.echo "Hello ", name
wscript.echo age, " is a good age"
Do get the input box to pop up we will use the InputBox command and use the = sign to assign what the user types in to a variable and then we are able to print the results on the screen. Now lets go a little further and lets have the program make a decision about what to do based on what the user types. To make this program make a decision we will be using the IF... ELSE IF... ELSE... statements.
' hello.vbs
' This is your typical Hello World program
name = InputBox("What is your name?")
age = InputBox("How old are you?")
wscript.echo "Hello ", name
If age 17 AND age 17 AND age
Mike Walton
CCENT, Network+, Security+
mwalton@mikenetpc.com
Mike Walton has been in the technology field for over 8 years and has 6+ years in hospitality technolgy. Mike has experience with Microsoft Windows Server 2000, 2003, Windows 98, XP, and Vista, Networking, Cisco Equipment, PCI DSS, and many more. Mike Walton is also the founder of MikeNet PC Free Articles and Videos.
What Is On YouTube Today?
Laptop Startup Race - Windows 98 vs. Windows Vista! (With Random Cattage)
Here Are Some Items From Amazon You Might Like.
![]() 3 Pack of Universal Touch Screen Stylus Pen (Red + Black + Silver) List Price: Sale Price: $0.01 You save: $29.98 (100%) Eligible for free shipping!Availability: Usually ships in 24 hours |
![]() 5 in 1 Card Reader for iPad List Price: Sale Price: $0.01 You save: $0.15 (94%) Eligible for free shipping!Availability: Usually ships in 1-2 business days |
![]() AmazonBasics Stylus for Touchscreen Devices Including Kindle Fire, Apple iPad 2, the New iPad, Motorola Xoom, Samsung Galaxy Tab, BlackBerry PlayBook Sale Price: $10.93 Eligible for free shipping!Availability: Usually ships in 24 hours |
![]() OtterBox Defender Series for the New iPad (3rd Generation) & iPad 2 - Black List Price: Sale Price: $47.00 You save: $42.95 (48%) Eligible for free shipping!Availability: Usually ships in 1-2 business days |
![]() GOgroove BassPULSE 2MX USB Powered 2.0 Channel Computer Speakers for Apple Macbook Pro , Air / Toshiba / HP / ASUS / ACER / DELL / Compaq / Sony Vaio / Samsung / Gateway & more Laptops / Desktops! List Price: Sale Price: $25.19 You save: $39.80 (61%) Eligible for free shipping!Availability: Usually ships in 24 hours |
![]() Marware Kindle Fire Clear Screen Protector 2-Pack with Cleaning Cloth - Lifetime Warranty List Price: Sale Price: $3.99 You save: $11.00 (73%) Eligible for free shipping!Availability: Usually ships in 1-2 business days |
![]() Sandisk 16GB MicroSDHC Memory Card, Class 4 List Price: Sale Price: $2.87 You save: $47.12 (94%) Eligible for free shipping!Availability: Usually ships in 1-2 business days |
![]() rooCASE Dual-View Multi Angle (Magenta) Genuine Leather Folio Case Cover for Amazon Kindle Fire 7-Inch Android Tablet List Price: Sale Price: $13.95 You save: $36.00 (72%) Eligible for free shipping!Availability: Usually ships in 24 hours |
![]() rooCASE Dual-View Multi Angle (Black) Genuine Leather Folio Case Cover for Amazon Kindle Fire 7-Inch Android Tablet List Price: Sale Price: $13.95 You save: $36.00 (72%) Eligible for free shipping!Availability: Usually ships in 24 hours |
![]() Newgen CRIPAD51 5-in-1 Card Reader for Apple iPad, iPad 2 & New iPad List Price: Sale Price: $0.98 You save: $19.01 (95%) Eligible for free shipping!Availability: Usually ships in 1-2 business days |
Items recently purchased on this site:
Thanks for visiting!























































































Eligible for free shipping!








