Computer Performance, Windows 2003, Logon Scripts

Google

WebSearch Site

 Home
Subscribe to Newsletter
WSH - Home
WSH - Simple Script
WSH - Create User
WSH - Bulk Import
WSH - Create Group
WSH - Create Contact
WSH - FSO Create File
WSH - List Members
WSH - Error Messages
VBScript Home
Logon Script Home
CSVDE & LDIFDE
 LDAP Attributes

 

 More Sections
 Guy's eBooks
 Windows 2003
 Exchange 2003 (New)
 Performance Monitor

 

 Windows 2000 AD
 Exchange 2000
 SQL Server 2000
 SharePoint Portal

 

 Litmus Tests
 Registry Hacks
 Problem Solving
 On-line advice
 Free ebooks

 

Contact Guy
About Us
Online Jobs at CP
Guy's eBooks

 

 

WSH - Simple Script

Introduction to WSH (Windows Scripting Host)

WSH (Windows Script Host) will become an important player in every network administrator's team.  The best way to get started is by writing simple scripts.  Feel free to amend my examples to suit your domain.  In fact, discovering what happens when you change a name here or command there, is the classic way to learn how WSH scripts work.

Topic - Simple WSH Script

The purpose of my sample script is to check the version numbers of WSH, VBScript, WMI, and ADSI.

 

This is what the output of your script will look like.  Note the subtle differences in the names of the 4 executables: WSH, VBScript, WMI and ADSI.  Check out the part of the script where the major and minor version numbers are joined (concatenated) to echo the final result.

 

˚

Simple Script

Here is a sample script to check your version of WSH and WMI.

 

 

'Script to display WSH, VBScript, WMI, and ADSI versions
'Script created by Guy Thomas

On Error Resume Next

WScript.Echo "WSH Version: " & WScript.Version

Wscript.Echo "VBScript Version: " & ScriptEngineMajorVersion _
& "." & ScriptEngineMinorVersion

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer _
& "\root\cimv2")
Set colWMISettings = objWMIService.ExecQuery _
("Select * from Win32_WMISetting")
For Each objWMISetting in colWMISettings
Wscript.Echo "WMI Version: " & objWMISetting.BuildVersion
Next

Set objShell = CreateObject("WScript.Shell")
strAdsiVersion = _
objShell.RegRead("HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{E92B03AB-B707-11d2-9CBD-0000F87A369E}\Version")
If strAdsiVersion = vbEmpty Then
strAdsiVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\ADs\Providers\LDAP\")
If strAdsiVersion = vbEmpty Then
strAdsiVersion = "ADSI is not installed."
Else
strAdsiVersion = "2.0"
End If
End If
WScript.Echo "ADSI Version: " & strAdsiVersion
 

 

Copy the above script into Notepad

Save with a .vbs extension, e.g. guydemo.vbs.

Double click to execute.

 

Try another script?

Create Users

The purpose of this script is to add Organizational units and users.

See Also

 *


Google

Web  This website

Guy Recommends: SolarWinds Engineer's Toolset v10Engineer's Toolset v10

The Engineer's Toolset v10 provides a comprehensive console of utilities for troubleshooting computer problems.

There are so many good gadgets, it's like having free rein of a sweetshop. Thankfully the utilities are displayed logically: monitoring, discovery, diagnostic, and Cisco tools.  Download your copy of the Engineer's Toolset v 10

 

Home Copyright © 1999-2010 Computer Performance LTD All rights reserved.

Please report a broken link, or an error.