Spaces in Parameters being passed to EXE doesnt work

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
gtdalsanto
Pro Scripter
Posts: 51
Joined: Tue Oct 03, 2006 4:22 pm
Location: Akron, Ohio
Contact:

Spaces in Parameters being passed to EXE doesnt work

Post by gtdalsanto » Wed May 12, 2010 7:07 am

Is there a way to pass parameters that have spaces in it. My problem is that I am trying to pass a file spec path to an executable to set up a variable within a macro, but it only sees the value upto the space. Below is an example of what I am trying to do:

c:\folder\macro.exe /PATH=c:\my documents\data\test.txt /VAR2=value2

Once macro.exe runs, the variable PATH is "c:\my" instead of "c:\my documents\data\test.txt". If there is no spaces in the variable value, there is no problems. Is there something I can put the string in so I can pull in the complete path? I have tried numerous things (quotes, etc) but nothing seems to handle the space.

Not sure if there is any built in solution here.

Thanks.
Gary T. DalSanto
Inventive Software Designs, LLC
[email protected]

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Put double quotes around parameters which contain spaces

Post by adroege » Wed May 12, 2010 12:34 pm

This is not just a Macro Scheduler problem, this occurs when passing parameters to almost any EXE on the command line. The solution is to put double quotes around the parameter which has spaces in it.

I compiled the following simple macro and tested that it works fine
MessageModal>PATH
MessageModal>VAR2


Change This:
c:\folder\macro.exe /PATH=c:\my documents\data\test.txt /VAR2=value2
To This:
c:\folder\macro.exe /PATH="c:\my documents\data\test.txt" /VAR2=value2

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts