Reputation: 29362
I have an AutoIT script here :
;Launch CMD
Run("C:\Windows\System32\cmd.exe")
sleep(2000)
$cmdHandle = WinActivate("C:\Windows\System32\cmd.exe")
Sleep(2000)
;Sending document
ControlSend($cmdHandle, "", "", "ftp" & @CRLF)
ControlSend($cmdHandle, "", "", "open" & @CRLF)
Sleep(2000)
ControlSend($cmdHandle, "", "", "first command" & @CRLF)
Sleep(2000)
ControlSend($cmdHandle, "", "", "second-coomand" & @CRLF)
first-command and second-command I can't provide cause it's internal. I have complied this .au3 file into an exe and it does the work. But I need to invoke this with Java. Java code I have tried is :
ProcessBuilder pb = new ProcessBuilder("C:\\Users\\username\\eclipse-workspace\\Examples\\src\\com\\own\\examples\\etc.exe");
pb.start();
Thread.sleep(5000);
Through java it just launches the cmd and nothing happens after that. Please help !!
Upvotes: 2
Views: 251
Reputation: 3102
Try sending /c
or the /k
switches as the first argument in your AutoIt script. This tends to be the requirements when sending arguments to batch-files or cmd related things from non cmd or batch instances. For example, try using:
ControlSend($cmdHandle, "/c", "first command" & @CRLF)
then see if it works from java.
Upvotes: 2