Jump to content

Quick help with the Run() function and passing parameters


Recommended Posts

Hey everyone, I am writing a script to launch a custom C# application that I developed, and this application accepts parameters from the command line. I know that it works, as I am able to run it from the command line just fine. I can even get it to run with the AutoIt script, using hardcoded values. However I need to pass the command-line arguments as a variable, so they can be changed easily. 

 

Here is what I have, that works perfectly:

Run('"C:\Users\Public\Documents\Merger.exe" "C:\Users\MattBrown\Documents\ProgramTestAllFiles\Def" "C:\Users\MattBrown\Documents\ProgramTestAllFiles\Sql" "C:\Users\MattBrown\Documents\ProgramTestAllFiles\output.xlsx"');

However, those long file paths are cumbersome. I made variables for them, but I can't seem to get the Run command to work with variables. Code below:

Global $DefFileFolder = "C:\Users\MattBrown\Documents\ProgramTestAllFiles\Def";
Global $SqlFileFolder = "C:\Users\MattBrown\Documents\ProgramTestAllFiles\Sql";
Global $OutputFile = "C:\Users\MattBrown\Documents\ProgramTestAllFiles\output.xlsx";
Global $MergerLauncher = "C:\Users\Public\Documents\Merger.exe";

Run('$MergerLauncher $DefFileFolder $SqlFileFolder $OutputFile');

I have tried many variations of that, with different " " or ' ' around the variable names, but I just can't get it to work.

 

Can anyone help me get this to run? I can also use ShellExecute, if that will work. As long as the arguments are passed separately, that will work. (I tried ShellExecute, but it passed all of my parameters as ONE argument, which won't work with my C# application).

 

Thanks!

Link to comment
Share on other sites

That doesn't launch the executable, it just skips over it and nothing happens.

 

HOWEVER, I did get it to work. I concatenated the strings, to make them one long command, and then just Run() it, like below. 

Global $runCommand = $MergerLauncher & " " & $DefFileFolder & " " & $SqlFileFolder & " " & $OutputFile;
Run($runCommand);

And that worked the way I needed it to.

 

Thanks for the help, MuffinMan. 

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...