# Batch File in Minimized Window



## DoubleHelix (Dec 10, 2004)

I want to execute a batch file in a minimized window on Windows 7, and I cannot find the options to do this. Everything I've found on the Internet suggests third party programs or wrapping it in a VB script. I tried running cmd.exe /?, but there aren't any command line parameters for window visibility. A shortcut with given properties won't work either. The batch file needs to be called directly from another program.


----------



## leroys1000 (Aug 16, 2007)

I am using this in a vbs file to call a batch file to restart media center.

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & "C:\Batch Files\syncfiles.bat" & Chr(34), 0
Set WshShell = Nothing

Setup same as a batch file but use the .vbs extension.

Change the batch file location and name to yours.
Call the .vbs file from your program.

The program calls the vbs file.
The vbs file runs the batch file in silent mode.
It runs in the background so no windows.


----------



## DoubleHelix (Dec 10, 2004)

As I said in my original post, I found plenty of references for wrapping the batch file in a VB script. That won't work for what I need it to.


----------



## leroys1000 (Aug 16, 2007)

That is the only way I have found to run a batch file in hidden
mode,after a lot of searching.
It calls just like a batch file.
Can I ask more specifically what you are trying to do?
Why a vbs file can't be used?


----------



## TheOutcaste (Aug 8, 2007)

What program is calling this batch file? A shortcut should work.
It will work if called from another batch file, but you have to use Start, not Call


----------



## leroys1000 (Aug 16, 2007)

Problem with calling a shortcut from a batch file is you end
up with a command prompt window.
The shortcut will run minimized if configured in properties.
It will minimize to the taskbar and leave a button there,
but the command prompt window will remain until the
process completes.
A vbs file works around that but the op says that won't work.
I went through the same thing with mine and tried every command
combination and shortcuts I could find and finally ended up with
the vbs solution.
I tried making a shortcut from a bat file and running minimized
with start and it had no effect on the window.


----------



## TheOutcaste (Aug 8, 2007)

He want's a minimized window:


DoubleHelix said:


> I want to execute a batch file in a *minimized window* on Windows 7


----------



## DoubleHelix (Dec 10, 2004)

I need to run a program after a Cobian backup process. The only options for executing a program are EXE, BAT, and CMD. That's it. Not VBS. Not LNK. I just don't want the command window opening in the middle of the screen every time it runs.


----------



## leroys1000 (Aug 16, 2007)

Might check task scheduler.
You might be able to run a scheduled task that can run the
vbs file when the program completes.
Only other thing I can think of.
The program could be used as a trigger maybe.

Looks like there are programs that can compile vbs to exe.
Might see if there are any freeware ones.


----------



## TheOutcaste (Aug 8, 2007)

Not perfect, but you can use a batch file to call the shortcut. You'll get a command window for about a second, then the minimized window will run, and the calling window will close.
You can use the Mode command to make it a small window, but you'll get a brief flash of the default sized window.

```
Mode Con Lines=1 Cols=16
Start mybatch.lnk
```
1 and 16 works on my system, you may be able to go smaller, may need larger. I think it depends on the size of the minimize, restore, close buttons.

Best option might be to use AutohotKey to launch the shortcut, and convert the *ahk* script to an *exe*. The exe doesn't need AutoHotKey to be installed, so would be portable:

```
run, mybatch.lnk
```
The above 17 byte file becomes a 207,025 byte exe, but should do what you want.


----------

