A good resource for all your scripting needs
Ever notice how you sometimes write a small batch file to automate something and then it starts growing and soon you start hitting the limits of what the batch file language can do and everything becomes an unmaintainable mess?
The natural solution then is to use Windows Scripting Host (WSH) and write a script in VBScript or JScript (or the many other languages it supports), since whipping out the VS IDE to code it in C# might be overkill for every little thing. The problem with WSH is that, as someone not very familiar with it, typically you don't know much about how to do particular things in WSH even if you pick up the basic VBScript or JScript language quickly. Even if you understand that most COM components can easily be accessed in WSH you still have the problem of knowing which COM components and/or interfaces to use for a particular task. For example there is a whole Scripting.FilesystemObject interface to help with common file operations and if you didn't know that then you'd be kind of lost.
So what do you do? Luckily there is an excellent resource which lists many scripting tasks neatly categorized with sample scripts. Its the Script Repository on the Windows Scripting site and all you need to do is look at some sample scripts for how to do a particular task. For example look under the Storage category for most file system tasks. One minor nit pick is that most of the examples are in VBScript. I personally prefer JScript, as I suspect most developers do, since its also a curly brace language like C/C++/C#. The scripting folks on the Windows Scripting site claim that most sysadmin type folks prefer VBScript hence the bias. But its not too difficult to convert the examples to JScript. If you are stuck then take a look at the JScript section of the additional language examples for some JScript samples that will give you some idea about how the same thing looks in JScript.
So chart your escape from batch file land and Happy scripting ...