VOGONS


Batch for running software in DOS

Topic actions

First post, by Exploit

User metadata
Rank Newbie
Rank
Newbie
Samir.Habib wrote on 2018-12-17, 19:32:
BeginnerGuy wrote:

The best solution you're going to get is to either have to put the time in to re-learn or learn DOS basics or just install win9x. There are too many reasons why windows 3.11 won't just exit and run any old DOS game....

To be honest, I've already figured out DOS, and typing all commands i need. ...

Instead of using a GUI menu system for launching DOS programs you can also use the power of batch files and a special bin folder for all your batch files.

Let's assume you have Wing Commander 2 installed in the directory C:\GAMES\WC2\ and you want have a lazy way with less typing to run it, then you can do the following:

1. Create a folder called C:\BIN

C:
CD \
MKDIR C:\BIN

2. Add that C:\BIN folder to your PATH variable in AUTOEXEC.BAT. In your AUTOEXEC.BAT the PATH variable typically looks like this:

PATH C:\DOS;C:\WINDOWS

just add a semicolon followed by your new C:\BIN folder:

PATH C:\DOS;C:\WINDOWS;C:\BIN

3. Now create a batch file for Wing Commander 2 in your new C:\BIN folder with the following content:

@ECHO OFF
C:
cd C:\GAMES\WC2
WC2.EXE

If WC2.EXE is not the command, then then take a look and change the name. After that, save the batch file as let's say WC2.BAT in your C:\BIN folder.
A more sophisticated batch file would check for the presence of the game's folder and the game's executable. You can add this if necessary.

4. Since executables in the local directory always have priority over the executables that can be accessed via the folders that are in the PATH variable, we need another command to be able to return to the C:\BIN folder easily.
Thus create a new batch file, let's call it simply and short GO.BAT with the following content:

@ECHO OFF
C:
cd C:\BIN

5. Now your C:\BIN folder should look like this:

GO.BAT
WC2.BAT

5. Another usefuel BATCH file is a batch command that lists all your files in your C:\BIN folder from any location. So create another file and call it GODIR.BAT

@ECHO OFF
DIR C:\BIN

If you are now in any folder on your system and then type GO.BAT, you will always jump back to your C:\BIN folder.
If you need from any location a listing of the contents of your C:\bin folder just enter GODIR.BAT.
And if you want to run WC2.BAT from C:\ or somewhere else, just enter WC2.BAT. This will run your BATCH file in your C:\BIN folder, as long as there is no other file called WC2.BAT in the local directory. The batch file will then switch to your Wing Commander 2 folder and run the executable there.

The C:\BIN folder can be extended with more BATCH files for more games as you wish.

Typing is thus reduced to a minimum and you don't need GUI menu programs that only take time to start and, in the worst case, require memory space in the RAM.

Reply 1 of 38, by Kekkula

User metadata
Rank Newbie
Rank
Newbie

What is the purpose of @ECHO OFF, I have never understood why is it used?
Is the only purpose to turn screen of for the patch to run? If so that's stupidest thing one could do. If there is any error in the patch it would not be visible.
Or have I missed something vital here, why would anyone want to hide the patch running?

Reply 2 of 38, by Exploit

User metadata
Rank Newbie
Rank
Newbie
Kekkula wrote on 2024-03-27, 20:03:

What is the purpose of @ECHO OFF, I have never understood why is it used?

If you write a batch file without @ECHO OFF, all commands you run in the batch file will be repeated in the output.

Is the only purpose to turn screen of for the patch to run? If so that's stupidest thing one could do. If there is any error in the patch it would not be visible.
Or have I missed something vital here, why would anyone want to hide the patch running?

Batch files are usually written carefully and you test them and if they work without errors you don't need an ECHO output of the commands that are to be executed.
With DOS there is also the problem that there is no output history. So you can't scroll back, which is why the 25 lines fill up very quickly.

Reply 3 of 38, by Jo22

User metadata
Rank l33t++
Rank
l33t++

+1

And the @ makes ECHO OFF turn itself being invisible.
If there was just ECHO OFF, the "ECHO OFF" line would be printed during boot.

Or in other words, @ECHO OFF makes things look more clean.
Programs and DOS commands (internal/external) being run in a batch file can still output.
But all the batch commands and their parameters are being nicely hidden during execution of a batch file.

ECHO can also be used as the equivalent to PRINT in GW-BASIC.
You can ECHO something to screen.

C:\>echo Hello world
Hello world

"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//

Reply 4 of 38, by chinny22

User metadata
Rank l33t++
Rank
l33t++
Kekkula wrote on 2024-03-27, 20:03:

What is the purpose of @ECHO OFF, I have never understood why is it used?
Is the only purpose to turn screen of for the patch to run? If so that's stupidest thing one could do. If there is any error in the patch it would not be visible.
Or have I missed something vital here, why would anyone want to hide the patch running?

Something like this is a good example.
You get a nice box around the text. without echo off it would look a mess
Re: Creating a DOS batch menu

Reply 5 of 38, by analog_programmer

User metadata
Rank Oldbie
Rank
Oldbie

This seems more like "the power" of PATH variable 😁

from СМ630 to Ryzen gen. 3
engineer's five pennies: this world goes south since everything's run by financiers and economists
this isn't voice chat, yet some people, overusing online communications, "talk" and "hear voices"

Reply 6 of 38, by Exploit

User metadata
Rank Newbie
Rank
Newbie
analog_programmer wrote on 2024-03-28, 10:21:

This seems more like "the power" of PATH variable 😁

Well, you need both. The length of the PATH variable is limited in DOS. So you can't add as many directories as you want. In addition, you need a way to differentiate between Wing Commander 2 (WC2.EXE) and Warcraft 2 (WC2.EXE) and therefore you cannot append all of their directories to the PATH variable. This distinction is possible with batch files.

Reply 7 of 38, by analog_programmer

User metadata
Rank Oldbie
Rank
Oldbie
Exploit wrote on 2024-03-28, 12:16:

The length of the PATH variable is limited in DOS. So you can't add as many directories as you want.

Well, the PATH variable length is limited by number of characters, but the memory space for variables can be set with COMMAND.COM. Also you may use "the power" of SUBST or other tricks to shorten the PATH var length. But maybe all this is somehow new to people who didn't use DOS in its prime years.

Anyway, I wanted to point out that without PATH this whole bat-files containing directory would be pointless.

from СМ630 to Ryzen gen. 3
engineer's five pennies: this world goes south since everything's run by financiers and economists
this isn't voice chat, yet some people, overusing online communications, "talk" and "hear voices"

Reply 8 of 38, by Exploit

User metadata
Rank Newbie
Rank
Newbie
analog_programmer wrote on 2024-03-28, 12:53:
Exploit wrote on 2024-03-28, 12:16:

The length of the PATH variable is limited in DOS. So you can't add as many directories as you want.

Well, the PATH variable length is limited by number of characters, but the memory space for variables can be set with COMMAND.COM. Also you may use "the power" of SUBST or other tricks to shorten the PATH var length. But maybe all this is somehow new to people who didn't use DOS in its prime years.

So you're willing to sacrifice valuable memory space so that your PATH variable can be longer.
Your last sentence and personal attack is pathetic.

Reply 9 of 38, by wierd_w

User metadata
Rank Member
Rank
Member

Beyond a certain threshold, maintaining a massive collection of batch files becomes onerous.

I personally like DA5. It has mouse support, nested menus, executes at the proper path level and returns after target program closes, can run on an 8088 with truly ancient versions of dos, and consumes very little memory in the background, in addition to having customizable colors, and supports hercules, cga, ega, and vga modes.

There is an abundance of such software out there in the digital ocean, but this is the one I personally like. Your mileage may vary.

At some point, the built-in management/upkeep tools in such packages become well worth the other expenses.

Reply 10 of 38, by analog_programmer

User metadata
Rank Oldbie
Rank
Oldbie
Exploit wrote on 2024-03-28, 13:33:

Your last sentence and personal attack is pathetic.

Look, I don't know what "personal attack" you're seeing here, but better off learn how things work in good old DOS. There's no need to reinvent the wheel, even if you're from oversensitive virtual generation Z.

from СМ630 to Ryzen gen. 3
engineer's five pennies: this world goes south since everything's run by financiers and economists
this isn't voice chat, yet some people, overusing online communications, "talk" and "hear voices"

Reply 11 of 38, by Exploit

User metadata
Rank Newbie
Rank
Newbie
analog_programmer wrote on 2024-03-28, 13:59:
Exploit wrote on 2024-03-28, 13:33:

Your last sentence and personal attack is pathetic.

Look, I don't know what "personal attack" you're seeing here, but better off learn how things work in good old DOS. There's no need to reinvent the wheel, even if you're from oversensitive virtual generation Z.

This is a personal attack and it is particularly not an argument with which to support one's argument:

analog_programmer wrote on 2024-03-28, 12:53:

But maybe all this is somehow new to people who didn't use DOS in its prime years.

You're implying that I only discovered DOS now. And you are quite wrong. Because I was already using DOS, there wasn't even Windows 3.0 yet. So I most likely used DOS before you.

analog_programmer wrote on 2024-03-28, 13:59:

There's no need to reinvent the wheel, even if you're from oversensitive virtual generation Z.

And yet another personal attack because you can't gain any ground against me in the field of knowledge. Not only are you toxic, you're also pathetic, because instead of helping or to support your statement with arguments, you're looking for disputes.

And no, I don't agree with you to increase the memory requirement for the PATH variable so that more can fit in. Because the batch solution is the far more memory efficient solution.

Last edited by Exploit on 2024-03-28, 14:20. Edited 3 times in total.

Reply 12 of 38, by Exploit

User metadata
Rank Newbie
Rank
Newbie
wierd_w wrote on 2024-03-28, 13:50:

Beyond a certain threshold, maintaining a massive collection of batch files becomes onerous.

No, because you can use variables in batch files and thus use the same structure of a batch file for everything.

For example, if you define a variable for the game directory and the executable at the beginning of your batch file, then you only have to change the entry of these two variables and the rest stays the same.

Reply 13 of 38, by wierd_w

User metadata
Rank Member
Rank
Member

Children, please behave (and I dont mean poorly.)

I dont care how old we may be, or how grizzled our beards are getting (or even if we have beards at all), There's plenty of rabbit-hole in vintage OS tips and tricks country for everyone. New stuff still gets made, and new fun stuff is out there.

Even with old stuff, there's obscura and eratta that isn't well documented, that even old farts like me might not know about fully.

As such, never be judgemental, and look for and retain anything useful.

It's that simple, really.

Re, batch files:

This is, until you learn you need to change the common installed location on 1000+ batch files, and come to realize that blindly stabbing with regex replacement might 'not be ideal'.

Reply 14 of 38, by analog_programmer

User metadata
Rank Oldbie
Rank
Oldbie
Exploit wrote on 2024-03-28, 14:11:

You're implying that I only discovered DOS now. And you are quite wrong. Because I was already using DOS, there wasn't even Windows 3.0 yet. So I most likely used DOS before you.

If that were true, you'd make one handy menu based batch-file and not bother with all these nonsense. Good luck with discovering the secrets and "the power" of DOS commands, pal!

from СМ630 to Ryzen gen. 3
engineer's five pennies: this world goes south since everything's run by financiers and economists
this isn't voice chat, yet some people, overusing online communications, "talk" and "hear voices"

Reply 15 of 38, by Exploit

User metadata
Rank Newbie
Rank
Newbie
wierd_w wrote on 2024-03-28, 14:20:

This is, until you learn you need to change the common installed location on 1000+ batch files, and come to realize that blindly stabbing with regex replacement might 'not be ideal'.

This will be no different with a program starter.

Reply 17 of 38, by wierd_w

User metadata
Rank Member
Rank
Member

There are other issues one will come into contact with, concerning batch files, such as some programs not resuming batch execution after termination, which CAN be a dealbreaker, especially if you are doing something clever to make them run, such as emulating a cdrom with an iso file, since you wont have a good way to 'clean up' after the script execution.

Such programs will totally derail a CALL function, for instance.

Reply 18 of 38, by Exploit

User metadata
Rank Newbie
Rank
Newbie
wierd_w wrote on 2024-03-28, 14:32:

There are other issues one will come into contact with, concerning batch files, such as some programs not resuming batch execution after termination, which CAN be a dealbreaker, especially if you are doing something clever to make them run, such as emulating a cdrom with an iso file, since you wont have a good way to 'clean up' after the script execution.

Such programs will totally derail a CALL function, for instance.

I've never had such programs and never needed the CALL function in my batch files. But if batch files are affected, why shouldn't program launchers be affected when it launches such a program? The problem seems to be with the program's return function if it doesn't end cleanly.

Reply 19 of 38, by wierd_w

User metadata
Rank Member
Rank
Member

At least with DA5, it (the launcher) does not close. It remains in memory as a TSR, and initiates programs with a private shell. This allows it to 100% catch program termination, as the program returns to shell, which it traps, and then cleans up for.

The amount of memory is very small, just a few (like, 2 to 5. I'd have to check) kilobytes. Just enough to close the shell, and restart the menu system.