Solved

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

Posted on 2015-01-07
6
99 Views
Last Modified: 2015-02-02
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
Comment
Question by:100questions
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 40536612
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
 
LVL 69

Expert Comment

by:Qlemo
ID: 40536635
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
 
LVL 84

Expert Comment

by:oBdA
ID: 40536650
The thing with cmdow is that some AV flags it as potentially unwanted program, because it can hide open windows as well.
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

by:100questions
ID: 40538202
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
 
LVL 84

Expert Comment

by:oBdA
ID: 40538232
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
 

Author Closing Comment

by:100questions
ID: 40584638
Works very well, after I removed the pause.  Thanks.
0

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question