Q: How c an I ma ke others run my sc ripts?
VBScript would be a monotonous technology if you had to keep your scripts to yourself and run them only on your computer. Granted, that could prove to be a lot of fun, but people will, eventually, start looking at you strangely (maybe more strangely than they do now). You can only play scripting Solitaire for so long. Besides, what good is a management tool without the ability to use it across all computers in the company?
VBScripts can run on remote computers in a few different ways.
In a login script
From a network share
Copied to the remote computer
and executed there
From a web page
With a remote execution utility By utilizing Remote WSH
Lo g i n Sc r i p t s
Any company that has a network managed through a domain potentially utilizes login scripts. Login scripts allow network administrators to send instructions to the remote computer each time it logs onto the network. VB scripts work great when inserted into login scripts and make an excellent solution for making sure the scripts run on every computer in the organization. Some companies have even replaced their login scripts completely with VB scripts! OK, that’s just crazy, you say. Granted, some extreme knowledge of VB scripting is required, but it can be done and easily. If you remember how powerful VB script is, it may make better sense, realizing that if you have replaced your login scripts with VB scripts, you can utilize that power anytime you want, instead of searching the Internet for a freeware tool that will work in your environment.
Ex a m p l e o f V BSc r i p t I n se r t e d i n t o Lo g i n Sc r i p t
The following bit of VB script code provides an example of something you might want to place into your login scripts. This “codelet” simply maps the network drives O and Q for the computer logging into the network. With just a few lines of code, you can provide these network drive mappings.
Dim net
Set net = CreateObject("WScript.Network") net.MapNetworkDrive "O:", "\\server\share" net.MapNetworkDrive "Q:", "\\server\share"
N e t w o r k S h a r e
VB script works like any other application or program that executes on a local computer, so it’s not surprising that you can place a VB script on a network share that users have access to and have them run the script in some way. Just plop the script on the network, and offer a link to run the script. You can offer the link through an email, a login script, or some other method you
personally utilize to get software to the end-user. VB scripts work just fine using a hard-coded drive letter or a UNC path.
Ru n o n Re m o t e C o m p u t e r
Since VB scripts can run flawlessly on a local computer, it makes sense to understand that if you can get the script to the remote computer, it will run. Using any method you currently employ, just have the script copied to the remote computer into a directory you specify and formulate your plans to have the computer execute the script.
We b Pa g e
More and more companies utilize some kind of internal website for offering company information. Some go even farther by providing software downloads and installations. Websites are a great tool for company communications.
VB scripts run great from web pages—either through a link that executes the script, or a component that runs the script when a specific web page is loaded into the computer’s web browser.
R e m o t e E x e c u t i o n U t i l i t y
Several utilities on the market allow you to execute programs on remote computers. You just sit in the comfort of your cubicle, type out a few instructions on your keyboard, and the remote computer executes your commands. If you’ve watched many horror movies with a mad dictator or scientist, this is where you would hear an evil laugh emanate—Bwahahahaha . . .
One of the more popular tools in this area is from SysInternals. SysInternals offers a slew of freeware utilities geared toward aiding the systems administrator.
PsExec is the utility that allows remote execution of commands/programs. It doesn’t need to be installed on the remote computer, just run from yours, so there’s no overhead on the remote computer. PsExec utilizes the following command line options:
usage: psexec \ \ computer [-u username [-p passwo rd]] [-s] [-i] [-c [-f]] [-d] program [arguments]
Specifies optional user name for login to remote computer
Specifies optional password for user name— if you omit this you will be prompted -u
to enter a hidden password .
Run remote process in the System account.
Run the program so that it interacts with the desktop on the remote system.
Copy the specified program to the remote system for execution. If you omit this option, then the application must be in the system's path on the remote system. Copy the specified program to the remote system, even if the file already exists on the remote system.
Don't wait for application to terminate. Only use this option for non-interactive applications.
Name of the program to execute
Arguments to pass—note that file paths must be absolute paths on the target system .
You can download PsExec from the following location on SysInternals’ website: http://www.sysinternals.com/ntw2k/freeware/psexec.shtml.