How to start an application from a batch file without giving it focus (window 7)

I have a batch file with a for loop in which I run my application again (the application terminates by itself). I use:

start / wait / min myapp

so that it runs with a minimum value and expects self-updating. my problem is that the application steals the focus of the window every time it starts. How can I run the application without focus?

+3
source share
2 answers

my application is a C # form and the problem was topmost = true

0
source

You can use the Batch / JScript hybrid, so you can use the WScript.Run method.

With the second parameter = 7, you got it.

7 = ( . .).
MSDN

@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)

wait.bat

ping -n 5 127.0.0.1
+1

All Articles