Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.

You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.

As part of the development of an app, I'm doing the build process using the batch file. I might write a bit more about this at a later date. As the batch file grew I was wondering if it could do functions, to avoid using the same code multiple times. This page is a really good resource (http://www.dostips.com/DtTutoFunctions.php):

EDIT: Sorry the above link was a bit off topic. You didn't really ask for other batch file resources, did you? I will check out the link you gave. It's very handy to be able to use functions in batch files.

One big advantage of batch files is you don't have to install anything, so you can use them in restricted environments (i.e., work).

IMHO, the best thing to do with DOS batch commands is avoid using them.Try Take Command from JP Software.I used to use the precursor to Take Command, called 4DOS. It was superb. I gather from Wikipedia that 4DOS is pseudo public domain now.

But I'd avoid doing anything too complex with batch files unless you really, really have to. There are so many far better tools available (and most of them free). But you do usually have to make sure they're installed (or that a runtime is) if the script you're coming up with has to be able to run on machines you don't control.

AutoHotKey (and friends) is one of the exceptions as I understand it - build the script to an exe and nothing else is needed on the end-user's machine (I imagine that's one of the reasons it's quite popular on DC's coding snacks).

AutoHotKey (and friends) is one of the exceptions as I understand it - build the script to an exe and nothing else is needed on the end-user's machine (I imagine that's one of the reasons it's quite popular on DC's coding snacks).

If I may digress a bit...

Curious who you regard as "friends" -- AutoIt3 perhaps? Any others?

Some things that I found attractive about AHK / AutoIt3 included:

Conditions of use (e.g. free to obtain and produced output freely usable)

Relatively small resulting exe

Actively developed with a community of users

Decent selection of reusable code / libraries

For the things I checked some months ago, other things didn't seem to match these -- e.g. as I understand it, it's possible to create single exes for Perl and Python, but I don't think the results end up nearly as small as for AHK / AutoIt3. IDLE (based on Lua) seemed to produce relatively small exes, but the last time I checked there didn't seem to be much of a community and development didn't seem terribly active. Not sure about Factor yet -- still need to see how big the resulting exes are.

Curious to hear others thoughts on this topic...perhaps another topic / thread is in order...

I've been using a little freebie called BatchCompiler for some years, as a way to lock down batchfiles against casual modification and ensure maximum portability. (Can't remember where I got it now, and the readme only quotes the author's name -- Ricardo Arias -- but hey, Google is your friend.)

There are batchy things that it doesn't do well -- can't remember for sure, now, but CALLs might be one of those things -- but there are usually more than one way to skin the relevant cat and I've never found another batch compiler that worked as well.

Add in something like Reshacker so you can plug in your icon of choice and Tah Dahhh!

I've been using a little freebie called BatchCompiler for some years, as a way to lock down batchfiles against casual modification and ensure maximum portability. (Can't remember where I got it now, and the readme only quotes the author's name -- Ricardo Arias -- but hey, Google is your friend.)

Apparently, I wasn't Google's really good friend today

But I came across the following instead on a thread that mentioned BatchCompiler:

I've been using a little freebie called BatchCompiler for some years, as a way to lock down batchfiles against casual modification and ensure maximum portability. (Can't remember where I got it now, and the readme only quotes the author's name -- Ricardo Arias -- but hey, Google is your friend.)

Apparently, I wasn't Google's really good friend today

Obviously I should check these rash statements before I make them.

My copy of BatchCompiler's on a machine I'm not going to be anywhere near for another week, but if you want a look I've definitely got the original distribution zipfile on there, so if you don't find it beforehand, let me know your email privately and I'll get it to you sometime on the 27th. It's quite old, from memory, maybe 2003, so I guess the author decided he wasn't going to carry on supporting it...

@oblivion@ewemoa: Re: Batch Compiler.From memory, there was a batch compiler in 4DOS (I referred to 4DOS in a post above), but I never actually needed to use it except to try it out, so cannot comment on it.I did some googling using "Batch Compiler Ricardo Arias" search terms. I did find links/references to those terms - mostly in the Spanish language - but no download source for the Batch Compiler.On one site Purebasic.com there was this "user opinion":

Quote

Ricardo Arias, Argentina"I come from Visual Basic.Then I was searching for something small, with no runtimes, speed and easy too.Maybe PureBasic doesn't have that quantity of sourcecode available, but a great community that always help each other."

(By the way, reading about it on that site, I thought that PureBasic looked like a great Basic language + compiler. I might try it out,)

I guess nobody has taken to PowerShell yet, eh? . It is quite powerful, though I never thought a command line scripting shell could consume so many resources, lol. It is one massive beast. I dunno if anyone, even network engineers, have 'taken' to it yet.

Personally, I love Cygwin on Windows. Let's me have linux style scripting in Windows. Of course, I still use plenty of BATCH file for automation to this day.

I'd love to learn / get a hang of PowerShell. The problem is I have no clue what I can do with it that will make a time investment worth it, and I personally would probably be best served a set of ready-made scripts and examples that just let me be productive right off the bat.

Back on topic-ish now... Batch files I haven't really needed in years, and the looping facilities in it just make me cringe. Python usually sees to all my needs in that sense.

Yes, BATCH files weren't designed for complex scripting at all. Not like *nix shells, which were designed that way from the start. I still prefer *nix.

PowerShell, despite it being a resource hog like you wouldn't imagine, is very powerful. It can let you script almost anything you could code in .NET, minus all the UI stuff maybe. At least, that's my understanding of it. I have not taken the time to learn, nor care to learn, the internals of it either. Whether the product even survives remains to be seen. I'm sure some network admins are using it for some automation tasks, but that's about it. Nobody really took to it. They'd do better off pushing their POSIX subsystem on admins, and give them an interface common to Windows and linux. Of course, the *nix style scripting came from decades ago and isn't the most efficient thing in the world, but with the help of numerous facilitating tools you can do pretty much anything you want. PowerShell could have been much more efficient, and might be for large and very complex scripts, though its .NET MSIL overhead makes it slow .. so who knows on that one. They *did* include some unix commands in PowerShell, ironically.. at least named the same, different options and output format -- just to confuse people.

@kyrathaba: I didn't know anything about Windows Scripting until I read that post.I am not sure, but maybe this is what @mwb1100 was referring to when he wrote in the above thread:

Quote

The book "Windows NT Shell Scripting" by Timothy Hill has about the best coverage of how to do complex processing with batch files that I've come across (get a used/remaindered one for the cost of shipping).

@justice: Could this (Windows Scripting) be a potential alternative answer to what your original Q was about? (I ask the question in gnorance as to what your full requirements might be or why they might have necessitated the use of DOS batch in the first place.)