1

I am using the following very simple code to open outlook using the cmd line:

Start OUTLOOK.EXE

When I type it into the Windows Command Processor it works fine but when I use:

Runtime.exec(String[]{"Start ", "OUTLOOK.EXE"}); 

or

Runtime.exec("Start OUTLOOK.EXE);

or

Runtime.exec(String[]{"Start", " ", "OUTLOOK.EXE"});

In java it does not work (I get this error: Cannot run program "Start": CreateProcess error=2, The system cannot find the file specified) why ? I have read about spaces and runtime but I cannot get it working.

Thanks Ulrich


Ok so with some more googling I got it working:

Runtime.getRuntime().exec("cmd.exe /c start OUTLOOK.EXE");

That will open it, I hope people find this because I have been searching for some hours trying to figure out how to open a program I do not know the file path to.

  • possible duplicate of [How to Execute Windows Commands Using Java - Change Network Settings](http://stackoverflow.com/questions/7112259/how-to-execute-windows-commands-using-java-change-network-settings) – Brett Okken Jun 17 '14 at 18:59

1 Answers1

0

Do not use "start". Just having outlook.exe is enough.

Runtime.exec("OUTLOOK.EXE");
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78