Reputation: 2734
i have a batch file with a for loop, in which i launch my application repeatedly (the app terminates by itself). i am using:
start /wait /min myapp
in order to have it run minimized and wait for self-termination. my problem is that the application steals window focus each time it is run. how can i launch the app without giving it focus?
Upvotes: 3
Views: 3509
Reputation: 2734
my app is a c# form and the problem was having topmost = true
Upvotes: 0
Reputation: 82297
You could use a Batch/JScript hybrid, so you can use the WScript.Run method.
With the second parameter =7 you got it.
7=(Displays the window as a minimized window. The active window remains active.).
MSDN Run Method
@if (@X)==(@Y) @goto :Dummy @end/* Batch part
@echo off
setlocal
cscript //nologo //e:jscript "%~f0"
goto :eof
Jscript part begins here */
var sh=new ActiveXObject("WScript.Shell");
sh.Run("cmd /c wait.bat",7,true)
sh.Run("cmd /c wait.bat",7,true)
The wait.bat
ping -n 5 127.0.0.1
Upvotes: 1