Solved

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

Posted on 2015-01-07
6
100 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 70

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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

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 …
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

737 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