Jump to content

Run issue on all my scripts.


Carlo84
 Share

Recommended Posts

Hey all before i could use the Run command like this:

$myExe = 'D:\Documents and Settings\hs\Bureaublad\myExe.exe' ; Path with spaces
Run($myExe & ' "Param1" "Param2" "etc."')

But last night i stopped working, let Windows update while i went to sleep and the next day none of my scripts using the "Run" command work properly anymore, unless i do it like this.

$myExe = 'D:\Documents and Settings\hs\Bureaublad\myExe.exe' ; Path with spaces
Run('"' & $myExe & '"' & ' "Param1" "Param2" "etc."')

Have i always been doing it wrong in the past and just got lucky it worked, or did Windows update really messed something up here?

Im on Win "XP SP3" btw, also when i update all my apps, will it still function properly on Vista & Win7 ?

Link to comment
Share on other sites

Regardless of how/why it ever worked, best practice is to enclose any paths with spaces in quotes. Sure, it may work in certain environments, but why give yourself one more thing to regression test every time you update or run it in a new environment?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

But that would mean the Run command is to be used by double quotes, that seems rather odd to me.

Run('"D:\Documents and Settings\hs\Bureaublad\myExe.exe"') instead of

Run("D:\Documents and Settings\hs\Bureaublad\myExe.exe")

I never seen it done before like this.

Just a silly example but:

$file = FileOpenDialog("pickfile",@ScriptDir,"executable {*.exe}")
Run ($file)

would instead be

$file = '"' & FileOpenDialog("pickfile",@ScriptDir,"executable {*.exe}") & '"'
Run ($file)

Seems wrong to me.

I apologize if i'm totally looking at it wrong, autism makes some things just hard to understand sometimes :-p

Link to comment
Share on other sites

You are correct it doesn't matter if the command line doesn't require parsing out any parameters. What you are missing in your examples are parameters AFTER the executable path. That's the part that makes quoting the executable with spaces required. Otherwise, how many different ways might you parse a line with many spaces, some in the path, some between parameters, some inside the parameters, etc.?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

You are correct it doesn't matter if the command line doesn't require parsing out any parameters. What you are missing in your examples are parameters AFTER the executable path. That's the part that makes quoting the executable with spaces required. Otherwise, how many different ways might you parse a line with many spaces, some in the path, some between parameters, some inside the parameters, etc.?

:)

Thanks allot :-) makes perfect sense to me now
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...