Tuesday, July 25, 2006

Windows Scripting

KiXstart Your Scripting

Do you still open your text Document through series of mouse clicks such as Start Button>Programs>Notepad>File>Open and then selecting specific text file in specific folder, and finally clicking on OK button? Do you create a dozen new user accounts in your network one by one? Well, there are better ways to do these and lots of other things, thanks to Scripting.

A word about Script

Scripts are nothing but text files made executable, having cryptic words and sentences arranged in certain order and are saved with specific file extensions. For example, a text file having *.vbs extension will be a Visual Basic Script file, capable to do certain set of things according to instructions recorded in its text lines. Scripts are ones the properties of UNIX and Mainframe Computers and till release of Windows9x, and early version of WinNT, there were not much of support available in this era. But the scenario had drastically changed in favor of Windows and now there are tools that can help you write and run scripts natively for practically all version of 32 bit Windows, and are believed that, presently, Windows Scripting are far better than UNIX.

Logon scripts are the most commonly used and are indispensable tool for any system administrator. This is used to configure Windows environment for a user at the time of Logon, and is generally specific to a group of user. With the help of complex scripts, every kind of work including Computer management, Scheduling, Networking, Monitoring, Security, and task Automation etc. can be performed smoothly by simply running a single script file.

Tools for Windows Scripting;

While in UNIX / Linux, you can write shell scripts to run in any shell, and may not vary much for specific Shell, but in Windows, Scripts are radically different for specific environment. For example, VB Script are different than J Script, however may perform same set of tasks. You might have seen and at times have edited Batch files such as Autoexec.bat file in DOS / Windows9x. That file is the example of a simple shell script; and indicates how they are written to perform number of specific tasks automatically by running that single file. There are quite a large number of scripting tool available for Windows. Though you can use scripts in Windows9x / NT through some tools; scripts support are better and natively implemented in Windows 2000/2003/XP. Here are following tools that let you use Scripts in Windows:

1. Command Line or Command prompt

2. VB Script

3. J Script

4. Perl {Windows specific Implementation}

5. KiXstart

6. Python {Windows specific Implementation}

7. Rexx

8. ADSI [Active Directory Service Interface]

9. WMI [Windows Management Instrument through WSH, Windows Scripting Host]

If you have experience in JAVA or Visual Basic, writing J Script or VB Script respectively is relatively easy task and you only need to have to learn few basic things. Similarly, Language specific Scripts like Perl, Python, Rexx needs you to know the basics of those Languages. VB Scripts and J Scripts remain popular for quite some time in Windows and there is a tool WSH – Windows Scripting Host that lets you run either of these scripts in your system, either locally or remotely. There is a nice utility called WinBatch which can be used for writing powerful batch files having capabilities like stand-alone programs. Have a look at it at: http://www.winbatch.com

Write your first script:

If you are new to scripting, here is a very simple example of how a script is written and how it works. Here is how to write your first script in Command Line. This script, when run will open a text file in Notepad that you specify in the script. Open Notepad, type ‘Hello World’ and save it as Hello.txt file in root directory C:\. Now open Notepad again and type ‘notepad.exe C:\hello.txt’ without quote and nothing else, and save it as all files (and not as text file) having file name : Note.cmd or Note.bat . You can assign any name but take note that the file extension must be either cmd or bat so that Windows recognize it as executable file, and thus will able to run the commands which is written inside its text. Now run this file (Note.bat or Note.cmd as the case may be) through Run dialogue box or by simply double clicking it in Explorer. You will see that your Notepad is fired and it had opened your C:\Hello.txt file, where you will see your ‘Hello World’ written on it.

It seems that writing script is simple task. No. In reality, it may be as complex as coding a full program and thus may well expand to several hundred lines of code. Further, environment specific script differs well in their content and language and therefore is hard to understand. However, there are some tools and there are some ready made, easily adoptable scripts which can be of help in devising your scripts with little changes.

KiXstart: Windows Scripting the Fast Way:

KiXstart is a free-format scripting language and supports all version of 32 bit Windows. The only precondition is that KiXstart must be installed in the system as application or process. There are several, well documented commands available for use in KiXstart scripts. KiXstart supports COM automation & OLE functions. Scripts for KiXstart are easy, short and are capable to perform nearly all kinds of tasks such as Display information, Set Environment Variables, Start Programs, Connect to Network, Make Registry changes etc. There are some ready to use example scripts given in its Documentation for a start. For more information, visit http://kixstart.org.


Scriptomatic says: ‘Write script like a pro where the need of programming knowledge is not necessary’. Well, it is true in partial sense. Scriptomatic has several built in pre-written scripts and you need to copy-paste-edit them in your custom script, and you are done. Though most of the common task can be performed through Scriptomatic scripts with a little tweaking, you definitely need in-depth knowledge about how things work in scripts if you want to implement in your system administration task. Scriptomatic scripts are WMI / WSH based. For more information, visit http://www.microsoft.com/technet/scriptcenter/default.asp Scriptomatic is a freeware tool from the pocket of Microsoft, and is a fun while working with its ready to use scripts. There is a highly readable witty document ‘Write WMI Script like pros’ which makes learning Script writing with Scriptomatic a pleasant affair.


ScriptLogic claims that you need not hard code your scripts, instead simply start clicking your mouse in ScriptLogic Window several times and your scripts will be ready. Again, the task here seems simple, but in fact require the knowledge to where to click on its window to get desired result. ScriptLogic uses KiXstart scripting language and commands hence if you are comfortable with KiXstart, then it is advisable to build a rough script with ScriptLogic by mouse clicks and then fine tune the script through editing. Evaluation version of ScriptLogic is available at: http://www.scriptlogic.com

Sample Scripts:

If you feel little lazy in writing WMI scripts, relax. There are hundreds of ready to use sample scripts available free to download and use from http://www.microsoft.com/technet/scriptcenter/default.asp . For example, if you want to create 1000 user accounts for your Network, there is a script that spans only a dozen or so lines. Here, you can find reasonably good scripts for Computer management, Disk and File system, Enterprise Management, Files and Folder Management, Logs, Monitoring, Networking, Printing, Process, Services, Registry, Security, Task Scheduling, Users and Groups Etc.


Scripts are for productivity and for automation. OK –OK… but they are potentially dangerous for your system too. So, while you are testing a script, do so in a test machine, having your backup chore done already. Scripts are big brothers of Macros and perhaps you know what macro viruses can do.

Screenshot descriptions:

Script01.jpg: ScriptLogic, the scripting tool that lets you create Windows Scripts with simple mouse clicks.

Script02.jpg: Script Repository: hundreds of ready to use WMI scripts for variety of purpose can be found from various sources such as at: Windows .NET resource kit and at : http://www.microsoft.com/technet/scriptcenter/default.asp

Script03.jpg: WinBatch: The Batch file writer tool that gives you capability to write Windows Batch files having capabilities of standalone programs. Here, running a WinBatch script file is randomly displaying EFY group’s magazine names.

Script04.jpg: Scriptomatic: The tool that claims that you can yourself write Scripts like professionals. It has several built in scripts ready to use in variety of need.

No comments:

More Articles...

Translate in your own language

Want to translate this article in your own language? Just click the Flag below