beyonddc
beyonddc

Reputation: 1256

Java ProcessBuilder failed to execute my command

Without using the ProcessBuilder, I can run this command via the prompt successfully.

winexe --user \administrator --password foo //192.168.1.13 "msiexec /qn /i \setup.msi"

I am creating my ProcessBuilder via this constructor

ProcessBuilder(String[] commands)

The String[] arguments that I pass into the ProcessBuilder are as follow

[0] winexe
[1] --user \administrator
[2] --password foo
[3] //192.168.1.13
[4] "msiexec /qn /i \setup.msi"

The output looks like the below so I knew the ProcessBuilder is executing the command except the parameter that I am passing in doesn't seem to be correct. Can anyone spot what I did wrong?

winexe version 0.90
This program may be freely redistributed under the terms of the GNU GPL
Usage: winexe [-?|--help] [--usage] [-d|--debuglevel DEBUGLEVEL]
        [--debug-stderr] [-s|--configfile CONFIGFILE] [--option=name=value]
        [-l|--log-basename LOGFILEBASE] [--leak-report] [--leak-report-full]
        [-R|--name-resolve NAME-RESOLVE-ORDER]
        ...

Upvotes: 0

Views: 1606

Answers (1)

Judge Mental
Judge Mental

Reputation: 5239

you're confusing the ProcessBuilder command line tokens with the logical groupings of the command you are trying to execute. This command does not accept an argument "--password<space>foo", but the array's 3rd element tries nonetheless to pass such a thing.

Have you tried

[0] winexe
[1] --user
[2] \administrator
[3] --password
[4] foo
[5] //192.168.1.13
[6] msiexec /qn /i \setup.msi

?

Upvotes: 8

Related Questions