-5

I want to run an exe with a pre-argument in java. For example, if this is executed in a command prompt.

C:\> installutil myApp.exe

installutil is the pre-argument (or command) to myApp.exe. Here it is different than passing normal arguments to Runtime.getRuntime().exec() or Process.start();

Thanks.

millimoose
  • 39,073
  • 9
  • 82
  • 134
M P Mathugama
  • 1,418
  • 1
  • 20
  • 31
  • 13
    There's no such thing as "pre-arguments" in a command prompt. `runIt` would have to be an actual command, in which case `myApp.exe` is an argument to `runIt`. – millimoose Apr 30 '12 at 12:57
  • @Inerdial Please make that an answer. –  Apr 30 '12 at 12:58
  • But runIt is not an exe. So it gives an error when try to pass those as you said. – M P Mathugama Apr 30 '12 at 13:00
  • @PrasadMathugama Then you're missing something. `runIt` might be an executable in the current working directory of the command prompt, but not on the `PATH`, which is why your Java program won't necessarily pick it up. – millimoose Apr 30 '12 at 13:04
  • 1
    What would you expect for `$ runIt myApp.exe` to produce as result ? (compared to the normal execution of myApp.exe) – Olivier.Roger Apr 30 '12 at 13:04
  • well actually what I want is installutill myApp.exe. So please replace runIt by installutill which is microsoft installer tool. – M P Mathugama Apr 30 '12 at 13:08
  • myApp will not install unless use with installutil myApp. how I can achieve that with java? – M P Mathugama Apr 30 '12 at 13:13
  • @Prasad Then, where exactly are you using Java? If runit is a M$ tool, and myApp is an exe, what does Java have to do in all this? – Edwin Dalorzo Apr 30 '12 at 13:14
  • All I want to know is can't we achieve this in java? I am pretty sure there should be a way. – M P Mathugama Apr 30 '12 at 13:18

1 Answers1

9

There’s no such thing as "pre-arguments" in a command prompt. runIt would have to be an actual command, in which case myApp.exe is an argument to runIt.

It seems the program you're trying to run is part of the .NET framework SDK which does not get put on PATH during installation – you’re probably using the Visual Studio Command Prompt. On my machine the full path is C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe, it will be something similar on yours, you need to start the program using this full path.

millimoose
  • 39,073
  • 9
  • 82
  • 134
  • myApp will not install unless use with installutil myApp. how I can achieve that with java? – M P Mathugama Apr 30 '12 at 13:23
  • `installutil.exe` will be an executable file *somewhere*. MSDN tells me it's one of the .NET tools, so it's likely somewhere deep inside the Windows installation directory; and, more importantly, **not** on `PATH`. Find that executable, run it from Java, and pass `myApp.exe` as an argument. Use full paths to both executables. – millimoose Apr 30 '12 at 14:25