Sign in to follow this  
Followers 0
AutoJeff

Creating a Run statement in AutoIT3 involving a multi-nested command string with arguments

3 posts in this topic

I'm hoping someone can tell me how to create a Run statement in AutoIT3 involving a multi-nested command string with arguments. Although my inquiry is specific to a single command line, the problem would arise anytime AutoIT3 attempts to pass to Windows a particularly complex command with arguments.

In Windows, the following string, used in a desktop shortcut, will launch Firefox 24 ESR Portable (i.e., Firefox using its "own" profile in a directory below the one holding firefox.exe) in a window protected by Sandboxie:

"C:Program FilesSandboxieStart.exe" "F:Firefox 24 ESRcorefirefox.exe" -no-remote -profile "firefox 24 ESR"

The final portion of the string ( -no-remote -profile "firefox 24 ESR") points Firefox toward the directory holding the Firefox profile. Leaving out any of the sets of quotes in this string will prevent Firefox from launching properly in Windows.

As is my usual practice, I first tried to transfer this string into a Run statement by enclosing it in another set of parentheses, as well as opening and closing parentheses:

Run("C:Program FilesSandboxieStart.exe" "F:Firefox 24 ESRcorefirefox.exe" -no-remote -profile "firefox 24 ESR"")

However, in this form, AutoIT reports a syntax error after the first 3 characters, and stops processing: Run(""C

I then tried to remove the quotes around the command portions of the string, leaving only the profile name quoted:

Run("C:Program FilesSandboxieStart.exe F:Firefox 24 ESRcorefirefox.exe -no-remote -profile "firefox 24 ESR"")

That succeeded only in shifting the syntax error further right in the string: "firefox

I then tried changing the name of the profile directory itself, so that there were no breaks in that portion of the string:

Run("C:Program FilesSandboxieStart.exe F:Firefox 24 ESRcorefirefox.exe -no-remote -profile firefox")

That form permits the script to complete, and open Firefox under the control of Sandboxie. However, the profile is not loaded.

Next, I experimented with () around the revised profile folder name:

Run("C:Program FilesSandboxieStart.exe F:Firefox 24 ESRcorefirefox.exe -no-remote -profile (firefox)")

AutoIt3 then refused to process any part of the script, citing a "syntax error (illegal character)"

Then, I attempted <> around the entire profile instructions:

Run("C:Program FilesSandboxieStart.exe F:Firefox 24 ESRcorefirefox.exe <-no-remote -profile firefox>")

Again the script completes, but Firefox complains this time: "Your Firefox profile cannot be loaded. It may be missing or corrupt."

Enclosing only the name of the profile itself in <> produced the same result:

Run("C:Program FilesSandboxieStart.exe F:Firefox 24 ESRcorefirefox.exe -no-remote -profile <firefox>")

That does it. I'm just guessing at this point. Does anyone have any suggestions?

Share this post


Link to post
Share on other sites



Surround the whole command line in single quotes at either end, then the double quotes inside wouldn't be an issue.

Run('"C:\Program Files\Sandboxie\Start.exe" "F:\Firefox 24 ESR\core\firefox.exe" -no-remote -profile "firefox 24 ESR"')

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

I downloaded Sandboxie and FF portable. I couldn't get it to run correctly with a Run statement. Splitting the command and running it with ShellExecute did work for me. Here's some code to try:

$i = "C:\Program Files\Sandboxie\Start.exe"
$j = '"' & "F:\Firefox 24 ESR\core\firefox.exe" & '"' & "-no-remote -profile " & '"' & "firefox 24 ESR" & '"'
ShellExecute($i, $j)

RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
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
Sign in to follow this  
Followers 0