Author Topic: easy: Start a .bat file in a different window ?  (Read 697 times)

Space Between

  • Guest
easy: Start a .bat file in a different window ?
« on: January 21, 2003, 11:55:21 PM »
this must be easy for someone to figure out...must be...but i cant seem to think it out right.

I need to have a .bat file call or start another .bat file in a sepearate window....wait for that .bat file to exit and restart it again.

example:

MainBat calls or start\'s SubBat in a new window and waits for SubBat to close. After SubBat close\'s MainBat carries on and reopens SubBat again in a different window.

All this without user intervnetion.In win98 you can use the /w(ait) switch with the START command and everything is fine. However in win2k when you use the /wait switch once the .bat file it started close\'s it prompt\'s asking the user if he wants to aboart the batch script. Again win98 doesnt have that prompt.

legend:   window=[]  ex: [window]

[Mainbat]--->[SubBat]---FTP command\'s
[Mainbat]--->[SubBat]
[Mainbat]
[Mainbat]--->[SubBat]---FTP command\'s
[Mainbat]--->[SubBat]
[Mainbat]
[Mainbat]--->[SubBat]---FTP command\'s
[Mainbat]--->[SubBat]
[Mainbat]
[exit]

etc.... over and over again for X amount of times.   Mainbat waits for SubBat to close before restarting SubBat in a new window.

ARGGGGHHH!!!! man im aggrevated with this one HIGHLY for some reason. They have to be in seperate windows and the main has to wait is the problem. Really the problem is the main one wont wait. If i do start it just carries on to the next line, and if i do call it wont be in a seperate window. If only the /w switch with START wouldnt give that damn prompt it would all be really fun :-).

I know it should be able to be done with start and/or call but i cant figure it out.

Offline jiimmy

  • stranger
  • Newbie
  • *
  • Posts: 24
  • Karma: +0/-0
    • View Profile
easy: Start a .bat file in a different window ?
« Reply #1 on: January 23, 2003, 12:44:50 AM »
Did you try START /? ? All the info is there.

Try this.

Main.bat:
@ECHO OFF
ECHO.Command 1 ...
START \"TITLE 1\" /WAIT CMD /Q /C Batch.bat 1 A
ECHO.Done.
ECHO.Command 2 ...
START \"TITLE 2\" /WAIT CMD /Q /C Batch.bat 2 B
ECHO.Done.
ECHO.Command 3 ...
START \"TITLE 3\" /WAIT CMD /Q /C Batch.bat 3 C
ECHO.Done.



Batch.bat:
REM @ECHO OFF NOT NEEDED IF USING /Q SWITCH WITH CMD.
ECHO.Argument 1 is \"%~1\"
ECHO.Argument 2 is \"%~2\"
netstat -a
PAUSE



Another option is to just use:
START \"TITLE 1\" /WAIT Batch.bat 1 A

Then you have to exit the cmd interpreter from Batch.bat itself using the EXIT command.

Space Between

  • Guest
easy: Start a .bat file in a different window ?
« Reply #2 on: January 23, 2003, 03:21:20 AM »
Well i got it to work incase anybody is interested.

My 1.bat contains the below command and start\'s 2.bat in a different window. When 2.bat close\'s, no just by EOF like what CALL does...but actually when you close the window by \"pushing the x\"...it works without no prompts and carries on like it is a call function...seeing this let\'s you know it is simple..but can be overlooked obviously if your me. Took me almost 2 days off and on to figure it out.

(this is on 2k. 98\'s START/W does not give a prompt so its fine on it)

START /W CMD /C START /B /W 2.BAT

(note: without the /B 3 windows would be opened 1. for the first start, 1 for the second, and 1 for the .bat.)

obviously it start\'s another 32bit command processor and waits for that process to finsh. Since it is waiting for cmd to close..it does not matter how the .bat file terminates because the first START cares less.  Thus no prompt.

If you would do CMD /C START /W 2.BAT or START /W 2.BAT, and close 2.BAT by \"pushing the x\", you would recieve a prompt of \"^CTerminate Batch job? (Y/N).  Why? i dont know, it dont in win98. i can only guess it is because if your terminating the batch manually you most *likely* want to terminate the batch. There really should be a switch to turn that prompt off...but there is not.