Guest stevenk Posted May 19, 2005 Share Posted May 19, 2005 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. Link to comment Share on other sites More sharing options...
JerryD Posted May 19, 2005 Share Posted May 19, 2005 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 ) Link to comment Share on other sites More sharing options...
Guest stevenk Posted May 19, 2005 Share Posted May 19, 2005 Thanks JerryD I used Run ( '"' & $var1 & '" "' & $var2 & '"' ) and it works a treat Thanks again S. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now