Jump to content

What is the correct way to execute an AutoIt3 script in Java?


Recommended Posts

public static void runScript() throws Exception { 
        
        try { 
            
            ProcessBuilder pb = new ProcessBuilder("C:\\Program Files (x86)\\AutoIt3\\AutoIt3.exe\"", "\"C:\\Users\\Cameron\\workspace\\truecryptgui.au3\"");
             Process p = pb.start();
            
                
             System.out.println("Script executed, TrueCrypt volume created!");
        }
        catch (IOException e) { 
                System.out.println("exception happened - here's what I know: ");
                e.printStackTrace();
                System.exit(-1);
        }
        
    }

This is what I have right now, it prompts me with a window to select truecryptgui.au3 manually, however if I run from the cmd ->

"C:Program Files (x86)AutoIt3AutoIt3.exe" "C:UsersCameronworkspacetruecryptgui.au3" 

it functions automatically how I'd like it to.

Does anybody know what I'm missing in my Java code to get this to perform correctly?

Link to comment
Share on other sites

  • Moderators

Just out of curiosity, why the need to mix languages? Why not bring up a window with prompts, all as part of your main AutoIt script?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Remove the escaped quotation mark from just after AutoIt3.exe, or add another before C:. Your escaped quotes are imbalanced. Other than that, I don't see a problem. I tried your example after fixing the quotes, and it ran an AutoIt script just fine. What's the output when you run from the console?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...