Jump to content
dolphins

How to pass parameters with spaces to Run() or ShellExecute()?

Recommended Posts

dolphins

Hi,

I would like to start a new AutoIt program from an AutoIt program and pass parameters to the new program that contain spaces, like "Program Files".

Example:

$parm1 = "test"
$parm2 = "Program Files"
ShellExecute("newprogram.exe", $parm1 & " " & $parm2, @ScriptDir, "open", @SW_HIDE)

But when I parse the command line in "newprogram.exe" I have 3 parameters:
[1] = "test"
[2] = "Program"
[3] = "Files"

But I would like to have:
[1] = "test"
[2] = "Program Files"

How to achieve this?



Regards
Dolphins

Share this post


Link to post
Share on other sites
water

Put quotes around the parm.

$parm2 = '"Program Files"'

 

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
dolphins

Well, I tried that, but maybe  not in the correct way.

Let's say I want to pass @ScriptDir as 2nd parameter and @ScriptDir is "C:\Program Files\My Program". I tried the following:

ShellExecute("newprogram.exe", $parm1 & " " & '"' & @ScriptDir & '"', @ScriptDir, "open", @SW_HIDE)

But that gives a compilation error.

Share this post


Link to post
Share on other sites
JLogan3o13

@dolphins "a compilation error" doesn't help much, please post the SciTE output so we can see just what error you're receiving.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
water

Your code looks fine.
What error message do you get?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
JLogan3o13

Jinx! :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
dolphins

Folks, sorry for bothering you. I got it working. There was a stupd typo in my code. Here in the forum it was correct.

Thanks for your quick answers!

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

×