Solved

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

Posted on 2015-01-07
6
97 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
  • 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Title # Comments Views Activity
add text to end of existing text in file 16 72
Windows Batch File - Count Down 4 88
Nmap how to find wich type of socks is this? 4 107
Carriage Return in Batch File 5 66
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…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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