This is a followup question to one I previously asked:
start-program-if-not-already-running-in-java
I didn't get a great solution there (as there doesn't appear to be one), but I have a related question:
Is there anyway to launch an application in Java code (an .exe in Windows, not a Java app) and have it start minimized? Or perhaps to minimize it right after start? That would solve the focus issue from the other question and the already running problem would more or less deal with itself.
Clarification issues again: the Java client and the .exe are running in Windows and I really don't have the ability to write any wrappers or make use of JNI mojo or anything like that. I more or less need a pure Java solution.
Again, thanks for the help and I am more than willing to accept an answer that is simply: "This is just not possible."
Windows only:
public class StartWindowMinimized {
public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.err
.println("Expected: one argument; the command to launch minimized");
}
String cmd = "cmd.exe /C START /MIN ";
Runtime.getRuntime().exec(cmd + args[0]);
}
}
Sample usage:
java -cp . StartWindowMinimized notepad.exe
java -cp . StartWindowMinimized cmd.exe
To understand the arguments involved:
cmd /?
START /?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With