Carlo84 Posted February 25, 2011 Posted February 25, 2011 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 ? _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders
PsaltyDS Posted February 25, 2011 Posted February 25, 2011 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
Carlo84 Posted February 25, 2011 Author Posted February 25, 2011 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 _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders
Carlo84 Posted February 25, 2011 Author Posted February 25, 2011 (edited) [oops double post] Edited February 25, 2011 by Djarlo _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders
PsaltyDS Posted February 25, 2011 Posted February 25, 2011 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
Carlo84 Posted February 25, 2011 Author Posted February 25, 2011 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 _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders
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