VBScript - Getting Started
Getting Started with VBScript
This section is for beginners who are copying and pasting example scripts.
My sample scripts will work on Windows 7, Server 2003/8 and XP. Avoid other clients like Windows 98 unless you get the WSH updates
' VBScript to Display your ComputerName
If you are ready to move on then try: - Creating Computers
(If this script fails then you need a Windows or XP machine.)
I like the Permissions Monitor because it enables me to see quickly WHO has permissions to do WHAT. When you launch this tool it analyzes a users effective NTFS permissions for a specific file or folder, takes into account network share access, then displays the results in a nifty desktop dashboard!
Think of all the frustration that this free utility saves when you are troubleshooting authorization problems for users access to a resource. Give this permissions monitor a try - it's free!
Traps When Creating VBScripts
The first section of the VBScript, sometimes referred to as the header, states the purpose of the script and declares variables in Dim statements.
I like to start the script proper with Option Explicit because it forces me to declare variables. My reasoning is this, Option Explicit alerts me to errors, it halts the script if I miss spell a variable, or use the singular colItem whereas I declared the plural colItems in the Dim statement.
When we move into the middle section of the script, WMI prepares the ground by connecting to the root\cimv2. In the example below, once objWMIService gets a handle on the namespace, we select DiskDrive from Win32_'s many objects. Moving into the final section, VBScript loops through all the properties that we are interested in, and finally Echoes the results to screen.
If you like this page then please share it with your friends
See more VBScript examples: