views:

475

answers:

3

I created a java program that will pop up a dialog, and scheduled it as a task. Everything works fine except when the scheduled java program runs and the dialog pops up, there is another window (svchost.exe) hanging behind the dialog box and doesn't go anywhere until the java program finishes its execution. The program is running in Windows XP.

How can I avoid that dos prompt?

Thanks

+2  A: 

If you want your Java program to have no console window, you need to launch Java using javaw, not java.

Chris Jester-Young
+2  A: 

One word of warning (posting as an answer so I can get fancy links and for length): Services which pop up UI are basically security holes waiting to be exploited (search for "shatter attack" for more information). That's why in Windows Vista and beyond services cannot display UI on the desktop (services run in session 0, the interactive user runs in session 1).

More importantly, there are several scenarios in Windows XP where your application will fail to work: If there are multiple users on the computer logged on at once (fast user switching) or if the machine is a server 2003 machine running with the terminal server role your UI won't pop up in the interactive user's session.

This article talks about the session 0 isolation issue and how to work around it.

Larry Osterman
A: 

Create a shortcut for the thing you want to schedule. In the shortcut's properties dialog, Select Run Minimized in the shortcut tab. When scheduling this shortcut, make sure you refer to the shortcut, it ends in .lnk Browsing for it may bypass the shortcut for what the shortcut points to. Source: http://ask.metafilter.com/18994/Windows-Batch-File-Run-Minimized

Elan Riesman