Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 107
  • Last Modified:

How can I run a batch file minimized without employing the use of another batch file?

I would like to start a batch file minimized, without the need for the batch file to call another batch file to run.
ie.  start /min job.bat

I do not want the above scenario, but one batch file, which starts minimized.

Is there a way to do this?
0
100questions
Asked:
100questions
  • 3
  • 2
1 Solution
 
oBdACommented:
After a fashion; the batch can restart itself minimized and end the first instance.
This example will do just that, while keeping the arguments passed:
@echo off
setlocal
if /i not "%~1"=="/min" (
	start /min "Minimized Command Prompt" %ComSpec% /c ""%~f0" /min %*"
	goto :eof
)
shift
echo Argument 1: %1
echo Argument 2: %2
pause

Open in new window

0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
You can use a shortcut set up to start minimized.
Or use cmdow.exe, a free 3rd-party tool, to minimize or control windows including the own.
0
 
oBdACommented:
The thing with cmdow is that some AV flags it as potentially unwanted program, because it can hide open windows as well.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
100questionsAuthor Commented:
oBda, thank you.   Is there somewhere within that batch that I need to insert the name of the file or does it know automatically that it's running itself?
0
 
oBdACommented:
It'll automatically know its own name and path, that's what "%~f0" in line 4 expands to (enter "help call" in a command prompt for more possibilities).
You can add your own script content starting at line 8, or of course copy lines 1-7 at the beginning of an existing script.
In line 4, you can replace "Minimized Command Prompt" with whatever you want the window title to be.
If your existing script has "setlocal enabledelayedexpansion" at the beginning, adjust line 2 accordingly.
The script window will automatically close itself once it's done; if you want to keep the window open, replace the /c in line 4 with /k.
0
 
100questionsAuthor Commented:
Works very well, after I removed the pause.  Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now