Reputation: 153
Has anyone had any recent requirements for programming automated DOS Batch style tasks on a Windows box?
I've got some automation to do and I'd rather not sit and write a pile of .BAT files in Notepad if there is a better way of automating these tasks: mainly moving of files under certain date and time conditions, as well as triggering Windows applications before and after moving the files.
I am thinking along the lines of an IDE that has all the DOS commands 'available' to the editor with the correct parameter syntax checking. Is there anything like this out there, or should I be solving this problem with something other than .BAT files?
Upvotes: 6
Views: 881
Reputation: 470
I use AutoIt for this since PowerShell is not by default available at all machines. AutoIt offers a simple language with lots of default code you can re-use. AutoIt can compile to .exe.
I'm not sure what "Moving files under a certain condition" is but I once wrote Robocopy Controller script (using AutoIt) via which you can setup a copy script that fill be passed onto Robocopy.exe ("robust file copy" - a copy program which can be downloaded from Microsoft and is by default included with Windows Vista to replace xcopy). Maybe this free script of mine can be of assistance.
Upvotes: 2
Reputation: 2668
Although this isn't exactly what you're looking for, I'd opt for Perl. Lacking the GUI, Perl would allow you to complete your task quickly, and it's "glue" features would be helpful in future tasks you might have. Also, if one day you'll have to do similar things under another OS (which is not Windows), PowerShell might not be available, and your knowledge in Perl would come in handy.
Other than that - Perl's closest brother under Windows is definitely PowerShell.
Upvotes: 0
Reputation: 43615
Definitely PowerShell. It's Microsofts new shell with lots of interesting possibilities and great extensibility.
Upvotes: 4
Reputation: 5696
For simple Windows automation beyond BAT files, VBScript and Powershell might be worth a look. If you're wondering where to start first, VBScript+Windows Task Scheduler would be the first place I'd start. Copying a file with VBS can be as simple as:
Dim objFSO
Set objFSO = CreateObject ("Scripting.FileSystemObject")
If objFSO.FileExists("C:\source\your_file.txt") Then
objFSO.CopyFile "C:\source\your_file.txt", "C:\destination\your_file.txt"
EndIf
Upvotes: 6
Reputation: 64424
I'd recommend Python over Ruby as a Windows scripting language. Python's windows-support is much more mature than Ruby's.
Upvotes: 2
Reputation: 2046
vbscript/WSH is actually what Microsoft wants you to use - unfortunately, I've written a few of those and it is not pleasant -
I totally agree with Mikael - if you know what systems will be running the scripts and you can install interpretters on them, go with a scripting language like Python or Ruby
Of course it depends on what type of automation you need to do - if you're messing with the OS or Active Directory settings, go with WSH - but for your average file housekeeping, use Python or Ruby
Upvotes: 0
Reputation: 3151
Windows 98SE and up have Windows Script Host built in, which lets you use VBScript to automate tasks (see for example http://www.windowsdevcenter.com/pub/a/oreilly/windows/news/vbscriptpr_0201.html).
Upvotes: 2