Jump to content

run function with variable


Guest bobele
 Share

Recommended Posts

Guest bobele

Hello

I'm trying to run the following script:

#---------START SCRIPT---------------------------------------------------

dim dir

; usually, the %appdir% enviroment varialbe has a value of c:\program files\app 1\

$dir = EnvGet("APPDIR")

Run($dir\setup.exe)

#-----------END SCRIPT--------------------------------------------------

First Problem:

The run function does not start the setup exe, neither if I wrote:

- Run("$dir\setup.exe") (ok, it is not a string, but the $dir variable should be substituted), nor

- Run($dir\setup.exe) (it seems that it does not substitute the variable)

Second Problem

I have to put "" around the $dir variable, if not the run function would not be able to find the setup. I cannot change the value of the $dir variable, because she is taken over from a common setup.exe, where it is not possible to put double quotes around the path.

How can I start this setup.exe with a variable path?

Thank you

Bobele

Link to comment
Share on other sites

Guest bobele

Thank you this-is-me

Cool, so easy.

But how do I put double quotes around the value of the $dir variable?

Many thanks

bobele

Link to comment
Share on other sites

check out FAQ #7, I think that's the one that covers &.

Run('"' & $dir & "\setup.exe" & '"')

will put quotes around the whole string.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

alternatively, edit the $dir string and add some double quotes to the beginning and end.

yes, but really, you want quotes around the whole thing, including the exe, for windows to like it.

if you wanted to do it with command line options, here's how I'd do it:

Run('"' & $dir & "\setup.exe" & '" /a/b/c some option')

which would be passed to windows as:

"c:\program files\app 1\\setup.exe" /a/b/c some option

PS, I noticed that your env var has a trailing backslash, so you would probably want to either edit the returned variable, or just not add it before setup.exe.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

'course, plenty of ways to make it shorter... my way does make it easier to throw a variable in for setup.exe also just illustrates possibilities.

"I'm not even supposed to be here today!" -Dante (Hicks)

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