-2

My scenario is to open RUN window (Windows + R) and execute it programatically using java.

Please provide me the java code for it or suggest me how to proceed with it.

Steps:

  1. open RUN(WINDOWS + R).
  2. Run a program (say C:\ProgramFile\Internet Explorer\iexplorer.exe) using it.
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
siva
  • 15
  • 6
  • 2
    why would you use the Run Window to execute a command? Just execute it. – kratenko Dec 09 '13 at 12:47
  • 2
    See this stack for how to just run a command: http://stackoverflow.com/questions/3774432/starting-a-process-in-java – drew_w Dec 09 '13 at 12:47
  • 1
    why not just execute the command? why you want to open run? – aryann Dec 09 '13 at 12:48
  • sorry if i was not clear with my question. Let me explain it in detail. I am opening a .lrr(Load Runner Results) file. I was asked to open this file via RUN(windows + R) so that we can give input values here itself . But i want to do it programatically using java. – siva Dec 09 '13 at 13:42

1 Answers1

1

As already mentioned:

Process p = Runtime.getRuntime().exec(
    "\"C:/ProgramFile/Internet Explorer/iexplorer.exe\" your_file.lrr"
);

Also you can add more parameters like this:

Process p = Runtime.getRuntime().exec(
    "\"C:/ProgramFile/Internet Explorer/iexplorer.exe\" your_file.lrr /t /p foo"
);

Probably you have to watch out for the blanks in the path to your executable by adding double quotes (as you can see in my example).

bobbel
  • 3,327
  • 2
  • 26
  • 43
  • Thanks @bobbel , the code you gave above was the one i was expecting, it works fine.....:) – siva Dec 10 '13 at 08:24