background preloader

WSH

Facebook Twitter

WSH - Sample Windows Scripting Host file. WSH (Windows Script Host) will become an important player in every network administrator's team.

WSH - Sample Windows Scripting Host file

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. 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 = ". " Managing Desktop Administration using WSH and ADSI — ServerWatch.com.

By Marcin Policht In his latest article, Marcin Policht presents a useful scripting approach to dealing with local user and group accounts in Windows NT 4.0.

Managing Desktop Administration using WSH and ADSI — ServerWatch.com

The script will renaming the local Administrator account, reset the password, list the membership of a specified local group, and add any number of global groups into the specified local group. Delegation of Active Directory administration in Windows 2000 can be handled efficiently by granting different level of permissions on Active Directory objects.

Similarly, by using restricted groups settings of group policies, you can ensure that privileged groups will contain only specific accounts (the procedure for configuring restricted groups is outlined in the Microsoft Knowledge Base article Q320065). You can also use group policies to alter the names of built-in accounts -- Administrator and Guest -- which is a common practice of security-concious administrators. Fortunately, scripting can once again help in automating such processes. WSH - Home. The key word in understanding WSH is Host.

WSH - Home

WSH (Windows Scripting Host) provides the environment to run scripts like VBScript or JScript. This is a big improvement over running .bat files in the CMD/DOS 'host'. Another analogy is the way Internet Explorer acts as a 'host' for displaying Dynamic HTML. The more you learn about WSH, the more you realize how versatile this host is. For starters, it supports not only VBScript, but also JScript, Perl, Rexx and Python.

The secret of WSH, like any good host, is the ability to look after its guests; in this case to service WMI and ADSI requests. VBScript (or other scripting language) If WSH is the host or container, then think of VBScript as the glue. WSH in action Logon Scripts - Mapping network drives (Native WSH) Creating Active Directory objects - Bulk import of users (Using ADSI) Collecting operating system data - Memory, uptime or free disk space (WMI) Starting or Stopping services - Telnet, System Attendant or Netlogon (WMI) Windows 2000 Scripting Guide - WSH Overview. Microsoft® Windows® 2000 Scripting Guide The first time people encounter Windows Script Host (WSH), they often express some confusion.

Windows 2000 Scripting Guide - WSH Overview

What exactly is WSH? Is it a language, like VBScript or JScript? No; although WSH enables you to run programs written in these languages, it is not a language itself. Is it an object model, like WMI or ADSI? VBScript .Run. Run an external Command.

VBScript .Run

Syntax objShell.Run (strCommand, [intWindowStyle], [bWaitOnReturn]) Key objShell : A WScript.Shell object strCommand : The Command to be executed intWindowStyle (Optional) : Int value indicating the appearance of the program's window. Not all programs make use of this. bWaitOnReturn : Wait for the command to complete before continuing execution of the wsh script. If bWaitOnReturn is set to TRUE, the Run method returns any error code returned by the application. If bWaitOnReturn is not specified or FALSE, this method immediately returns to script execution rather than waiting on the process termination (and returns an error code of 0) Specifying the bWaitOnReturn parameter allows you to run programs synchronously (one at a time). Environment variables within the argument strCommand are automatically expanded.

If a file type has been properly registered to a particular program, calling run on a file of that type executes the program. Settings for intWindowStyle: How to use the Windows Script Host to read, write, and delete registry keys. The Microsoft Windows Script Host (WSH) is a tool that allows you to run Microsoft Visual Basic Scripting Edition and Microsoft JScript natively within the base operating system, either on Microsoft Windows 95 or Microsoft Windows NT 4.0.

How to use the Windows Script Host to read, write, and delete registry keys

It also includes several COM automation methods that allow you to do several handy tasks easily through the Windows Script Host Object Model. The Microsoft Windows Script Host is integrated in Windows 98. It is available for Windows NT 4.0 from within the Windows NT 4.0 Option Pack. It is also available for download from the following site: The Windows Script Host provides several useful methods to read, write, and delete registry keys easily. Important This section, method, or task contains steps that tell you how to modify the registry. . ( ) How to back up and restore the registry in Windows The Microsoft Visual FoxPro code below demonstrates several examples of reading, writing, and deleting registry keys and values.