I have a java program to open a webpage in IE. And so I have this code -

Process p = Runtime.getRuntime().exe(“C:\\Prgram Files\\Internet Explorer\\iexplore.exe” “http://google.com”);

This works fine in Vista when UAC is disabled. The process keeps running until the webpage is closed.

With UAC enabled - it opens 2 IE browsers and immediately reaches the code p.waitFor(); and the process stops.

What changes should be made to make this work properly. I need to have UAC enabled. Any help is much appreciated.

9 Years
Discussion Span
Last Post by masijade

Uhm, try maybe Desktop.open()?

And the code always immediately reaches p.watFor(). It's just that it will stay there until the process is ended.


Process p = Runtime.getRuntime().exe(“notepad.exe");

I tried this and it works perfectly fine. it opens a notepad and p.waitFor(), waits till the notepad is closed. Once closed, it then exits the program.

But for IE, it opens IE and just exits the program.


Execute that command in a command shell once. You get the prompt back immediately, don't you? Well, the same thing happens by runtime.exec. The command you are calling starts another process that actually shows the browser, and then exits. In any case, as of 1.6 you shouldn't really be calling those things yourself. Use the Desktop class and it's open method, and let the system decide what should be used to show the document. Not only is this usually much more stable, but it is also platform independent, which runtime.exec is not.


I will try that.
But is this very specific to vista?
Because the same command - opens a browser window, launches the webpage and the process waits till the page is closed - when UAC is disabled.
Also with UAC enabled, if I turn the IE protected mode OFF, it works fine too.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.