[comp.windows.ms] How may I automatically run a batch upon startup of DOS shell?

kerce@nu.cs.fsu.edu (Kingsley F. Kerce) (11/05/90)

I've had no success with automatically executing a batch file once a
command.com session is started in a window.  NOTE THAT the batch file
will not run an application that I want to stick with--I just want to
stay at the command line processor after the batch runs.

Thanks in advance,
--
Kingsley Kerce kerce@nu.cs.fsu.edu | Overheard in a donut shop...
Computer Science (or Psych) Dept   | Man #1 : I wish I could walk forever.
FSU, Tallahassee, FL, 32306        | Man #2 : You wish you could walk forever?
Work Phone: (904)644-8562

c60c-3fz@e260-3f.berkeley.edu (In Sik Rhee) (11/05/90)

In article <KERCE.90Nov4123453@nu.cs.fsu.edu> kerce@nu.cs.fsu.edu (Kingsley F. Kerce) writes:
>I've had no success with automatically executing a batch file once a
>command.com session is started in a window.  NOTE THAT the batch file
>will not run an application that I want to stick with--I just want to
>stay at the command line processor after the batch runs.

Ok, here's the way to do it (tricky, but works)

you're gonna create 2 batch files... in the first one, lets call it dos.bat,
you type in the name of the second batch file (Don't CALL it, just execute
it).  The second batch file is the one you will want to run... so for ex.

DOS.BAT will have:
	@echo off
	go

and GO.BAT will have what you want to do...  it'll give you a prompt after
go.bat is finished...  I forget the exact reason why it does this, but it's
gotta do something with having to "CALL" a batch file from within a batch
file...  anyway, it works, so why complain :)

dhf@linus.mitre.org (David H. Friedman) (11/06/90)

.  I had a similar problem, when I wanted to open a DOS window and load
some TSR's, then wait at the prompt. I think what I did is:
  1) Set up a PIF for the DOS window (e.g., COMMAND.PIF)
  2) Set the PIF to execute e.g. COMMAND.BAT
  3) COMMAND.BAT loads the TSR's (read: runs your application), then
     loads a DOS subshell (the last line of the file is C:\DOS\COMMAND)
  4) You're left looking at the DOS prompt from the copy of COMMAND.COM
     that was loaded by the batch file. To get out, enter EXIT from the
     keyboard, and the window should close. You may get a message from
     Windows saying something like: "your TSR is ready to run. To exit
     this window, enter Control-C..." in which case ^C gets you out.

timur@seas.gwu.edu (The Time Traveler) (11/06/90)

In article <1990Nov5.100924.27076@agate.berkeley.edu> c60c-3fz@e260-3f.berkeley.edu (In Sik Rhee) writes:
>Ok, here's the way to do it (tricky, but works)
>
>you're gonna create 2 batch files... in the first one, lets call it dos.bat,
>you type in the name of the second batch file (Don't CALL it, just execute
>it).  The second batch file is the one you will want to run... so for ex.
>
>DOS.BAT will have:
>	@echo off
>	go
>
>and GO.BAT will have what you want to do...  it'll give you a prompt after
>go.bat is finished...  I forget the exact reason why it does this, but it's
>gotta do something with having to "CALL" a batch file from within a batch
>file...  anyway, it works, so why complain :)

I tried this, and I can't get it to work.  I told the .PIF file to load
DOS.BAT, and then I tried loading COMMAND.COM /C DOS.BAT, and that didn't
work either.

In both cases, it opens and closes the DOS window.  And at 25Mhz, I can't
even see what it's doing!!!

Timur

------------------------------------------------------------ The Time Traveler
Your daddy works in porno
Now that mommy's not around                                 timur@seas.gwu.edu
She used to love her heroin                               HE891C@GWUVM.GWU.EDU
But now she's underground              - Guns N' Roses

ms33@prism.gatech.EDU (Mike Sullivan, a.k.a. Sully) (11/14/90)

In article <2311@sparko.gwu.edu> timur@seas.gwu.edu () writes:
>In article <125407@linus.mitre.org> dhf@linus.UUCP (David H. Friedman) writes:
>
>But this means that you effectively have three copies of COMMAND.COM
>in memory!!!...

Ok, I've kept my mouth shut till now.  Will someone PLEASE explain
what is wrong with just using 4Dos???  It loads in a command
processor, and runs a batch file for all those neat ram-res programs
that people love.  It even has more features than Command.com.  It's
not a general solution, but is very practical.  It does everything
that I want it to, and it seems better than the suggestions that have
been floating around.  If you don't like it fine, but please remember
it is an option before saying that the only/best solution is in OS2
etc...

Mike Sullivan

One of many Michael P. Sullivans, my views are expressly my own, and are not 
endorsed by my boss, fellow workers, or any other Mike Sullivan. :-)
----------------------------------------------------------------------------
Internet: ms33@prism.gatech.edu     |      Ga.Tech, Atlanta Georgia, 30332

fritz@urz.unibas.ch (11/15/90)

In article <2310@sparko.gwu.edu>, timur@seas.gwu.edu (The Time Traveler) writes:
> In article <1990Nov5.100924.27076@agate.berkeley.edu> c60c-3fz@e260-3f.berkeley.edu (In Sik Rhee) writes:
>>Ok, here's the way to do it (tricky, but works)
>>
>>you're gonna create 2 batch files... in the first one, lets call it dos.bat,
>>you type in the name of the second batch file (Don't CALL it, just execute
>>it).  The second batch file is the one you will want to run... so for ex.
>>
>>DOS.BAT will have:
>>	@echo off
>>	go
>>
>>and GO.BAT will have what you want to do...  it'll give you a prompt after
>>go.bat is finished...  I forget the exact reason why it does this, but it's
>>gotta do something with having to "CALL" a batch file from within a batch
>>file...  anyway, it works, so why complain :)
> 
> I tried this, and I can't get it to work.  I told the .PIF file to load
> DOS.BAT, and then I tried loading COMMAND.COM /C DOS.BAT, and that didn't
> work either.
> 
> In both cases, it opens and closes the DOS window.  And at 25Mhz, I can't
> even see what it's doing!!!
> 
The problem with the /C qualifier of COMMAND.COM is that immediately
after execution of the command line specified after /C the COMMAND shell
is closed and you're back in your WINDOWS environment.
Nevertheless you can use the whole thing very well. Here is an example
how I use it:

I run emTeX as a DOS application. I need to have extended environment
memory because I need to set some variables (%TEXINPUT% etc...).

So I write in the .pif file: COMMAND /E:512 /C emtex.bat

The EMTEX.BAT itself contains the following lines:

@echo off
call set-tex.bat                  (* sets all the variables *)
ncsmall


When I execute the .pif file it calls emtex.bat and emtex.bat calls
the Norton Commander, which is very convenient when you want to 
work with emTeX. When I leave ncsmall (F10) I return immediately
to windows because now the emtex.bat is "over".

I hope someone can use this rather complicated procedure too.

Good luck.

		Oliver Fritz, University of Basel, Switzerland