Sign in to follow this  
Followers 0
Guest stevenk

variables in Run()

3 posts in this topic

Hello,

I have only just started with all this so go easy.

I want to be able to pass two variables to the Run() function but don't seem to be able to do it. I have tried adding a & symbol like this:

...

Run($var1 & $var2)

...

I have also tried putting quotes around everything like this

...

Run('"' & $var1 & $var2 & '"')

...

In the end I had to concatonate the two variables, plus a space to make another variable which I could use, like this:

$var1 = "program1.exe"

$var2 = "project.xml"

$var3= $var1 & " " & $var2

Run($var3)

What am I doing wrong.

S.

Share this post


Link to post
Share on other sites



If your program path ($var1) or parameter ($var2) have spaces in the values like:

$var1 = 'C:\Program Files\ProgDir\Prog.exe'

$var2 = 'C:\Documents and Settings\userid\My Documents\data.dat'

both of your examples won't run properly. Your first example would evaluate to:

C:\Program Files\ProgDir\Prog.exeC:\Documents and Settings\userid\My Documents\data.dat

and the second sample to:

C:\Program Files\ProgDir\Prog.exe C:\Documents and Settings\userid\My Documents\data.dat

The second sample fails because it sees "C:\Program" as the command to execute, and "Files\progdir\prog.exe" as a parameter to the command.

Try:

Run ( '"' & $var1 & '" "' & $var2 & '"' )

which should evaluate to:

"C:\Program Files\ProgDir\Prog.exe" "C:\Documents and Settings\userid\My Documents\data.dat"

Another alternative is to force all short file names:

$var1 = FileGetShortName ( "C:\Program Files\ProgDir\Prog.exe" )

$var2 = FileGetShortName ( "C:\Documents and Settings\userid\My Documents\data.dat" )

Run ( $var1 & ' ' & $var2 )

Share this post


Link to post
Share on other sites

Thanks JerryD

I used Run ( '"' & $var1 & '" "' & $var2 & '"' ) and it works a treat

Thanks again

S.

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