AutoRun working too well

  • Thread starter Thread starter David Winfrey
  • Start date Start date
D

David Winfrey

I wanted a batch file to run when I started the command shell,
so I added to HKEY_CURRENT_USER\Software\Microsoft\Command Processor
a new string, AutoRun="d:\usr\home\cmdsetup.bat".

It worked perfectly, until I ran a program that used spawn()
to call another program. In a loop. A long loop. And at
every iteration of that long loop, my cmdsetup.bat got
executed.

Is there some way (short of upgrading to Win98) to set up an AutoRun
that will execute only when the shell is started by clicking on the
desktop shell icon, and NOT when the shell is run from inside some
other program?
 
In said:
I wanted a batch file to run when I started the command shell,
so I added to HKEY_CURRENT_USER\Software\Microsoft\Command
Processor a new string, AutoRun="d:\usr\home\cmdsetup.bat".

It worked perfectly, until I ran a program that used spawn()
to call another program. In a loop. A long loop. And at
every iteration of that long loop, my cmdsetup.bat got
executed.

Is there some way (short of upgrading to Win98) to set up an
AutoRun that will execute only when the shell is started by
clicking on the desktop shell icon, and NOT when the shell is
run from inside some other program?

Why not point that shortcut (in)directly to cmdsetup.bat instead?
Possibly with adjustments like CLS and no EXIT statement.
Sonething like
CMD.EXE /k d:\usr\home\cmdsetup.bat

But perhaps this all can be done otherwise, depending on what
cmdsetup.cmd actually does... ?
 
:
: Why not point that shortcut (in)directly to cmdsetup.bat instead?
: Possibly with adjustments like CLS and no EXIT statement.
: Sonething like
: CMD.EXE /k d:\usr\home\cmdsetup.bat

Thanks, but the solution I finally resorted to was simpler;
I added a line to the batch file to test for the existence of
one of the variables that the batch file sets. If it finds
%USRPATH% in the environment, it knows it's running as a child
of itself, and exits immediately. Not a perfect solution, but
a working one. I should have figured it out sooner; that's a
standard way to prevent double inclusion of C header files.
 
Back
Top