|
-
October 2nd, 2003, 07:53 AM
#1
Batch file behavior
I want to make sure that I understand this correctly.
Suppose I make a batch file like so:
@echo off
defrag c: /F /SNE
scandisk c: /AUTOFIX /SURFACE
Is it the default behavior of a batch file to finish one command before it starts another?
Thanks all, Dex
-
October 2nd, 2003, 08:07 AM
#2
NO, I have all my game servers setup like that. I added 3 q3 servers in a batch file command and I have YET to come across a switch that makes it wait before one program is done. all a batch file does is run the program...it doesnt care about anything else...
Anyone else know of a switch that will make the .bat file wait for one program to be done?
-
October 2nd, 2003, 08:12 AM
#3
Yes. The batch processor functions exactly as if you typed the commands from the command line. Leaving aside any possible external influence like TSRs, once an executable like scandisk (which of course should be run before defrag... ), has control, the batch processor is not functional until the program ends and the DOS EXEC function hands control back to the batch processor to process the next batch instruction.
Edit: we are talking about a DOS batch file aren't we?
Last edited by Platypus; October 2nd, 2003 at 08:15 AM.
-
October 2nd, 2003, 08:57 AM
#4
If that is true, why were my game servers starting all up at once? Was I not putting in the right commands?
-
October 2nd, 2003, 09:25 AM
#5
I wondered too when we reached different conclusions. Being in the Win3.1/DOS forum, I guessed the .bat was being run in real DOS, in which case what I said should be correct, DOS is not multi-threaded. What OS were you running the batch under, TangZ?
Once a Win32 server is started, it's an independent process in its own right, the batch file, as you say, is not aware of it any more and goes on with what it's doing. If programs are being run in DOS, it's quite different.
Last edited by Platypus; October 2nd, 2003 at 09:40 AM.
-
October 2nd, 2003, 09:42 AM
#6
AHHHH you are correct I completely forgot it runs different in real mode on older versions (I run 2000 and XP), but the commands should be the same... shouldnt they?
-
October 2nd, 2003, 09:47 AM
#7
I think the commands would be the same, except for any Win2000 or XP enhancements to the batch language. The difference would be I'm assuming Dexahol's query is for real mode DOS.
-
October 2nd, 2003, 11:35 AM
#8
Just to clarify, this is a pure DOS 6.22 machine.
Dex
(And I believe platypus answered the question, Thanks.)
-
October 2nd, 2003, 12:12 PM
#9
ummm, just a little curious...whay would you WANT an all dos machiene? why not UNIX or LINUX....?
-
October 2nd, 2003, 01:24 PM
#10
heh-heh - the answer would fill a book, but since I don't have that much time or space. . . I'll hit the highlights:
DOS is simply fun. I never wonder what DOS is doing behind my back.
I'm using it to develop an in-car mp3 player using MPXPLAY. DOS is unique in that it can be shutdown with the power switch.
I also play with QuickBASIC 4.5. It just works better, (read: simpler), in the pure DOS environment.
Then there's all the old games that I occasionaly play.
Experimenting with batch files, without worry about wiping out something important.
And then, there's just the ability to maintain ones familiarity with the command prompt, without worrying about the impact of a mistake. I can completely reinstall my DOS system in about 5 minutes. (With all software.)
The list goes on forever!
Dex
Edit: Almost forgot the most important of all. With older machines being available at flea markets for $10 - $50, you can have one of each: DOS, Win3.x, Win 9.x, Linux, for the cost of a decent sound card. Switch them through a KVM switch, and you can do anything.
Last edited by Dexahol; October 2nd, 2003 at 01:26 PM.
-
October 2nd, 2003, 02:57 PM
#11
In car cd player through dos huh...Id love to see some info or prototype pics on that if you have it posted on the web!!!
-
October 2nd, 2003, 05:27 PM
#12
I would put:
@echo off
call scandisk c: /AUTOFIX /SURFACE
call defrag c: /F /SNE
This makes it come back to the Batch file when the process is done. Otherwise it may run scandisk and stop. You might add
pause
between the commands if it does run through to the second command. That would be primarily for Windows.
------------------
My
Two Cents
Dennis
Visit Politalk
-
October 2nd, 2003, 06:59 PM
#13
TangZ; This is actually a pretty popular thing to do. Peruse this forum for a bit.
BTW - It'll actually be an in-car MP3 player, with hard drive. (No CD)
Eeyore; I probably shouldn't have used that example. The "defrag" and "scandisk" thing was purely for the sake of example. The actual commands I'll be using are some various Norton Utilities functions that I want to automate.
But I do appreciate your comments. I will store that info away just for reference.
Dex
Last edited by Dexahol; October 2nd, 2003 at 07:03 PM.
-
October 3rd, 2003, 05:48 AM
#14
If you're running Windows 9x and you want DOS to wait for one of your program to finish before starting another, prefix the first program with "START /W". For example:
Code:
@echo off
:SCANFRAG.BAT
start /w scandskw /allfixeddisks /noninteractive /silent
defrag /all /f /detailed /noprompt
for %%x in (cls exit) do %%x
Now DEFRAG won't start until SCANDSKW has exited.
For more info, typeat any DOS prompt and see this Microsoft KB page: How to Start Programs Sequentially in Windows
-
October 3rd, 2003, 07:12 AM
#15
Thanks for that great info and link Vernon.
I didn't know that.
Dex
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|