Re: Command prompt tool to minimize a command window AFTER it starts?



"Herb Martin" wrote in message
> I have a program which spawns a filter command (batch file) and does it by
> running CMD.exe in an open window which has the annoying habit of coming
> to the front and taking focus.
>
> I need a tool to push the command prompt to the background and better to
> minimize it -- my intent is to run it as the first line of the batch.
>
> Is there a better way? (Other than fixing the stupid program which calls
> it which I cannot do directly.)

You can rewrite the main Batch file as a Subroutine shell, and have
the Batch file recall itself in a minimized window before passing control
to the main code and closing the initial window.

Patch your own code into this outline (where I've placed the relevant
ECHO command):

Lines that don't begin with two spaces have wrapped accidentally
====Begin cut-and-paste (omit this line)
@ECHO OFF
IF [GOTO:]==[%1] GOTO %2 {Subroutine-Handler}
start /min "CMD window" "%0" GOTO: _MAIN %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
@ECHO OFF
CLS
EXIT

GOTO EOF {=Subroutine-section-below=}
:_MAIN
FOR %%C IN (1 2 3) DO SHIFT

ECHO. Your Batch code goes here

:EOF {End-of-file}

====End cut-and-paste (omit this line)
Simulated Win2000 for study/demo use. Cut-and-paste as Batch text file.
Batch file troubleshooting: http://www.allenware.com/find?UsualSuspects

The outline passes any Batch parameters (up to %9) to the _MAIN
child shell, and restores their normal positions.

For an explanation of the unusual combo of lines:
@ECHO OFF
CLS
EXIT
to close the initial window, see our Usual Suspects page
http://www.allenware.com/find?UsualSuspects
and look under item
"Window stays open" MS-DOS window doesn't close (or closes too soon)

--
William Allen
Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
Batch Reference with examples http://www.allenware.com/icsw/icswref.htm
Header email is rarely checked. Contact us at http://www.allenware.com/


.



Relevant Pages

  • Re: Run batch file on exit of program?
    ... A windows program will run and the batch will continue a soon as he program has started. ... > command window closed before I exited the GUI ... > close after you exited the GUI program. ... > @echo off ...
    (microsoft.public.windowsxp.general)
  • Re: Batching Updates?
    ... If you batch run them, they will automatically wait for one to finish before ... Echo Applying IE 5.5 Post-SP2 Hotfixes to system. ... Echo Reboot to activate changed files. ... >>the network login script or a batch file run on the ...
    (microsoft.public.security)
  • Re: Batch File execution problems
    ... I want each of these to load into ... What happens when I run the following batch recommended by Dave ... > is that a DOS window opens up and On the top ... >> @echo off ...
    (microsoft.public.windowsxp.general)
  • Re: Multi-zip files -- Windows server
    ... native DOS versions). ... TO BATCH OR NOT TO BATCH ... and using a batch file to try and solve the problem... ... The IBM PC operating system command line is a most ...
    (comp.sys.cbm)
  • Re: EWF RAM
    ... Do you mean it is running the stress test fine locally on the device? ... If it does and the issue has no repro, you should move to use local batch file approach in your support scenario. ... >> A tech plugs into it with laptop and remote desktops to it. ...
    (microsoft.public.windowsxp.embedded)