
SAPIEN homepage
PrimalScript script editor+ide
PrimalScope script debugger
Free Tools script utilities
SAPIEN Press tech books
ScriptingAnswers.com learn+share
ScriptingOutpost.com online store
Blog.Sapien.com official blog
Contact Us

Have you written a script that accomplishes some administrative task? Please share it! Just navigate to the appropriate category and click the "Contribute to this category" link!
You are here: Top > Misc VBScript or WSH
Contribute to this category
Sub-Categories
(no categories are available)
Scripts
.CMD vs. .VBS Contributed by Marshall
For the longest time I've been a slave to .CMD and .BAT solutionsturning my nose up at VBScript solutions because I simply didn't need them, or need to know anything about them, but this can no longer beconsidered to be the case. MSH is right around the corner and while I considered it 'OK' to keepmyself 1 technology behind by not absorbing VBScript I can't allow myself to be 2 scripting technologies behind the times. Editor's note: Backslahses get stripped from code samples unless you format them specially... I'm putting pipe (|) characters in in place of the backslashes that should be in here. Sorry for the inconvenience. Both of these examples are dependant upon the existance of a SERVERS.INI file to be created by you prior to running them. SERVERS.INI is a flat text file which should contain the hostname or IP address of each system you wish torun the script against. (1 hostname or IP address per line)Add users to local groups Contributed by Eric Ekstrand
This script simply adds a user id or global group to a local group on a workstation or server. Any questions please email me at eric@xstrand.comBasic HTA Example Contributed by Don Jones
This demonstrates how to construct a very basic HTA. It doesn't actually do anything other than display text, but its simplicity makes it easier to see the special parts of an HTA. It starts with a basic HTML document. Included is an HTA: tag which defines the HTAs behavior, such as whether it has a scroll bar and whether or not multiple instances are allowed to run. Next is a SCRIPT tag which contains the script code. Notice that the HTA is event-driven; one section of script runs when the windows loads (the Window_OnLoad event) and another when a button named btnOK is clicked (the btnOK_OnClick event). This is how a traditional Windows app works, and makes HTAs very robust. The remainder is simply FrontPage-generated HTML, which comprises the "starting point" for the HTA, e.g., what it displays when you first run it and before the Window_OnLoad event fires. As you can see this is a basic HTML form, nothing fancy, except that all the controls - the text boxes and button - are given specific names, so that they can be referred to from script code. The script also demonstrates the use of the DIV tag. This tag is invisible and the starting HTML doesn't have any text in it. However, the DIV is named, which allows the script code to refer to it and modify its InnerHTML property. This permits text (well, HTML, really) to be inserted into the DIV tags, creating a dynamic display.Checking WSH Versions Contributed by donj
Windows Script Host (WSH) 5.6 provides enhanced security capabilities and the latest VBScript features. Before you start deploying scripts, it's a good idea to make sure all of your clients have it. Of course, you can deploy WSH with Group Policy, but how can you be sure everyone's received it? One quick-and-dirty way is to create a VBScript logon script that will tell you. Set up a shared folder that all users can write files to. Modify the below script with that shared folder's servershare UNC, and assign this script as a logon script. What you'll get is a single text file for each computer that doesn't have WSH 5.6 installed. The file will be named after the computer and will contain the WSH version that is installed - all you need to get the latest version of WSH fully deployed.Convert Html Files To DOC using VBS Contributed by Iamindian
This script demonstrates how applications like IE and Word, which are exposed as COM components, can be automated from within a script.Customer Invoice Manager Contributed by Marcus L. Farmer
I started this project as a study in how extensible HTAs can be. It is still very much a Beta project and I will be working on it more as time goes by. As the project stands now, though, it is workable if you create the database, tables, columns, and stored procedures.
You can download the HTA and its supporting files from here.Generates HTAs from scratch, with all available options explained. Contributed by HtaTools
A hta that will explain all of the available options that go into building Hyper Text Applications. The tool will provide all of the necessary explanations and links to Microsoft's site on HTA Reference. I have also added the most common elements I use in most of my hta's; + like how to size the window + a Status window for posting live updates to your app's progress + a Reset button to clear all of the setting within the window + a Quit button to properly quit your application This is a fully functional tool, ready to use.Get Microsodt KB Article Contributed by Marcus L. Farmer
Run the script and type in the number of the KB article you would like to view. Script will open Internet Explorer and take you to that article.HTALite Framwork, rev b Contributed by Mark A. Connor
This is a scaled down version of a Framework for building .HTA applications that allows you to quickly and easily create a consistent User Interface (UI) for all your .HTA applications. Basic functionality includes a ToolBar, pageContent area that facilitates multiple screens, and a good statusbar. Additional functionality is provided through methods of the pplication object. Easy to use and understand. Zip file includes the .HTC file that provides the bulk of the work. Sample application is provided to demonstate some of the framework's functionality. You'll need your own images for the toolbar but a few are provided for demo purposes.IE selection box Contributed by Stephan King
This shows the use of a selection box is IE.Internet Explorer Debugging Window Contributed by Don Jones
Simply add this to any script and use Trace("whatever") to write debugging information. I recommend writing the values of any variables or object properties after you change them, so you can keep track of what your script is doing. This is a poor substitute for a professional debugger like PrimalScope, but if you're poor... well, this is free! When you're done debugging, add "Exit Sub" as the first line of the Trace subroutine. You'll be able to leave your Trace() calls in place, but the IE window will stop coming up.Log Off User Only During Specified Hours Contributed by Andrew Czerlinsky
This script will checks a time range and compares it with the current time on the computer and performs an action, in this case a log off, if the current time is either greater than or less than and excluded time period. I used this because there isn’t a way via command line to create a Windows scheduled task that would have a start time and an end time, as well as only if idle for x amount of minutes. You can manually set this in the advanced properties of a task, but you cannot set this up from the command line. This made a deployment of a job that would log off users after 30 minutes of inactivity only between the hours of 6am – 6pm impossible without touching every computer. In this case, I create a scheduled job via command line that runs after 30 minutes of inactivity which then runs this script. The script checks the time and if the current time is not within the exclusion range, it logs off the user.LookupExtensions.vbs Contributed by Christian Sawyer
Ask for an extension type and lookup on filext.com to find the associated program and give detail description. The input could be with dot (.) or without it and the extension. You must not specify a prefix before dot (.) or the extension.Make your script wait Contributed by droopy
When you call an external object, let's say a command-line tool, by default, your script will not wait for the process to complete. It ran the tool, so it thinks that it's job is done and its time to move on to the next line. What if the next line requires that the previous action is completed first. If that's the case, the easiest way to do this is to monitor the process that you called and see if it is still running. Think of this as the script version of Task Manager. Basically, this code says, if you still have that process running, then wait 2 seconds and check again. It repeats this until it does not see the process anymore. The code below uses notepad as an example. This code opens notepad and waits until you close it before continuing.Name Multiple Excel Sheet in one loop Contributed by Christian Sawyer
Create as many sheets in an Excel workbook as you want and name it as you want from any array, text file, etc... Will name all sheets in one loop. You then can use another sub to fill each sheet during naming one by one or fill each sheet at a later time.Nicephotogs site-blaster.js auto web Builder WSH(N2,3beta updt.) Contributed by Samuel A Marchant
Updated 26-10-2007.[This is a shortened zip go to the site(s) to download full system.] This script runs in a system hierarchy of its folders to automatically produce web pages from a simple .txt configuration+content file. The output is a web page for each configuration+content file that is placed in the INSERT directory. Effectively you can have a folder of 100s of conf+content files and if any are modified you can rerun all of them.That is not the favourable until the page template is adjusted to "perfect", its real idea is to leave as little /eliminate fiddly editing as possible. Added to the system is an auto generated ror.xml sitemap and PHP emailer script with associate form. (shorterned zip!!!) To know how to operate it properly "YOU MUST USE THIS URL": http://www.nicephotog-jvm.net/nicephotogs-site-blaster.js.html The zip also can be downloaded from http://www.nicephotog-jsp.net site.Nicephotogs site-blaster.js auto web Builder WSH(N2,3beta) Contributed by Samuel A Marchant
This script runs in a system hierarchy of its folders to automatically produce web pages from a simple .txt configuration+content file. The output is a web page for each configuration+content file that is placed in the INSERT directory. Effectively you can have a folder of 100s of conf+content files and if any are modified you can rerun all of them.That is not the favourable until the page template is adjusted to "perfect", its real idea is to leave as little /eliminate fiddly editing as possible. Added to the system is an auto generated ror.xml sitemap and PHP emailer script with associate form. (shorterned zip!!!) To know how to operate it properly "YOU MUST USE THIS URL": http://www.nicephotog-jvm.net/nicephotogs-site-blaster.js.htmlNicephotogs SUcommanderXer Java2 pre beta commandline and batch scripter Contributed by Samuel A Marchant
The application is applicable here for people whome use Batch .bat, WSH or ASP. While it is not the greatest IDE for scripting(neither for commandline running; a dangerous action you must elect yourself but there are instructions to how to terminate the program at my site and in the zip file) it does have editing benefits since anyone scripting in windows probably knows more languages or windows languages. The operator list helps as much the tools for choices to know of for your script. The zip here only contains the help-use page from my site and instructions for download. Essentialy its freeware designed for editing help, but is for people who have some idea of what they are constructing(not quite novice). (The application can be downloaded at my site after registration. Requires Sun Microsystems JRE 1.4.0 or better)ProcessBlock Contributed by Scott Klassen
Checks to see if there is a specific program running. If it is, a MsgBox will pop up to let you know, if not then it will start the program. You will have to set the process name with the name of the program executable and the full path including the executable name in the script.Quick and Dirty IE Scripting Contributed by Don Jones
This script creates a list of running services and displays them in a script-controlled Internet Explorer dialog box. It's a demonstration of how scripts can control IE completely to create more complex dialogs than permitted by the MsgBox() statement.Quto Defrag Contributed by Quefz
This is a VBS script which only runs on windows XP and 2003 ServerSchedule an animated message using MS Agent Contributed by Iamindian
This script shows how to use animated Microsoft Agent characters (kind of like the Office Assistant) from VBScript.Send email via Script Contributed by Eric Ekstrand
You can use this script with other scripts to send an email message. This is very basic, but can be enhanced.Simple using IE as a user interface Contributed by Don Jones
Demonstrates how to control IE from within a script as a means of displaying HTML-formatted messages.strSelectFolder.vbs Contributed by James Robertson
I use the function all the time in my scripts. Just CnP it into any VBS file and use it. It is well documented, so you should not have issues. You can use the function to prompt for a computer name via a browse to box, or create a folder on a server, or whatever you need it to do. Read the comments and url's provided in the script.WSH, WMI Admin Scripts 07 Contributed by Pat Reilly
I built this file up from microsoft examples, then added functions i needed for myself. Its an HTML file which uses javascript to create and execute vbscripts at the command line. Anytime you click a button the vbscript is created in a file called c:\temps.vbs. when opened you must say yes to ActiveX. Too many functions to mention, i call it my "Network Admin Script". feel free to contact me about it - scriptit@itat.co.ukWSH, WMI Admin Scripts Contributed by Pat Reilly
I built this file up from microsoft examples, then added functions i needed for myself. Its an HTML file which uses javascript to create and execute vbscripts at the command line. Anytime you click a button the vbscript is created in a file called c:\temps.vbs. when opened you must say yes to ActiveX. Too many functions to mention, i call it my "Network Admin Script". feel free to contact me about it - scriptit@itat.co.uk