Computer Performance, VBScript

 

VBScript - For Windows Networks

Introduction to VBScript

This section provides you with free tutorials of VBScripts for Windows Server 2003 and XP.  Many of the scripts are designed to create and manipulate Windows Active Directory objects.  Each page has a tutorial explaining the methods you need to tackle a particular every-day network task.  In addition to the scripts themselves, I provide learning points to explain how the VBScript builds objects such as Users, Computers and Groups.

Treat this page as a a mini sitemap for free VBScript examples.

VBScript Sections

Windows Server 2003 Active Directory Example Scripts

Creating and Controlling Files with FSO (Scripting.FileSystemObject)

Registry

  • RegRead - Introduction to RegRead
  • RegRead - Read the Registry Advanced

 

WMI (Windows Management Interface)

WMI gives you the power to automatically collect hardware and software data.  View WMI as a pipe connecting magically to the secret inner cave of the Microsoft operating system.  This is a section for techies who want VBScripts to remotely control of their Windows networks.  Study root\cimv2 here:

 

 

®

General Scripting Techniques

Each script has two missions:
a) A practical task that reveals properties of the Windows operating system.
b) A theoretical technique to demonstrate a pure VBScript command.

 

  • Binding to Active Directory
  • Object based model
  • Writing to files with FSO
  • Select Case
  • For ... Next loops
  • If ... then Else ..  End if logic
 
  • error-correcting code
  • On Error Resume Next
  • WScript.Echo
  • InputBox

VBScript Background

VBScript in Windows Server 2003 conforms to the classic Object programming model.  Objects such as Users have properties for example 'givenName' and 'description'.  The most interesting part is the methods because they are used to manipulate the object, for instance, GetObject, CreateObject and ConnectObject.  More often than not, the goal of our script is to set a value for a particular properties, for example Object = User, Property = givenName, Value = Guy.

It can be hard to pin down VBScript.  There are no stand-alone executables, you do not compile VBScript as you would with C++.  How does it work, I can hear you asking.  Well VBScript works through a host WSH which reads plain scripts, compiles them and runs them.  This means what ever is in those scripts is what gets done.

Example VBScript to create a user with a first name (givenName) of Guy.

 

 

' GuyUsers .vbs
' Free VBScript to create a User in Users .
' Author Guy Thomas http://Computerperformance.co.uk/
' Version 1.3 - August 2005
' ------------------------------------------------------'
Option Explicit
Dim strUser, strFirst
Dim objRootLDAP, objContainer, objNewUser, objShell
strUser = "GThomas"
strFirst = "Guy"

' Bind to Active Directory, Users container.
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://cn=Users," & _
objRootLDAP.Get("defaultNamingContext"))

' Build the actual User.
Set objNewUser = objContainer.Create("User", "cn=" & strUser)
objNewUser.Put "sAMAccountName", strUser
objNewUser.Put "givenName", strFirst
objNewUser.SetInfo

WScript.Quit

' End of example Create Guy VBScript.

VBS Learning Points

Note 1: This is just an example of VBScript.  It illustrates the Object, Property and Value structure.  It creates a User object (not a computer object).  This example assigns the property givenName a value = "Guy".

ˇ

Next Step

Site Home   Creating Users      Creating Folders    WMI - Basics

 


Introduction to VBScriptDownload my eBook:  Introduction to VBScript - only  $6.25

25+ scripts to get you started with VBScript.  Topics include Active Directory, Network, WMI, File System Object and the Registry.

In addition to the ebook, you get a PDF and a Word version of Introduction to VBScript.

 

 

 

 .


Google

WebComputerperformance.co.uk

If your computer is in need of some toner cartridges get th best deals from Click Inks.com. Find cheap printer ink online for any printer. Home or business, we have the right epson ink cartridges for your printer.

 

Home Copyright © 1999-2008 Computer Performance LTD All rights reserved

Please report a broken link, or an error.

 

link popularity checker