madasraka Posted October 12, 2010 Share Posted October 12, 2010 Script 1 executes script 2 Script 2 reads .ini for path to executable and then executes it. .ini says: Path1=F:\Installed programs\amsn\amsn loader.exe Folder F:\Installed programs\amsn has "amsn.exe" and "amsn loader.exe" Why instead of specified "F:\Installed programs\amsn\amsn loader.exe" script 2 executes "F:\Installed programs\amsn\amsn.exe" ? Script 1: run (@ScriptDir & "\Script 2 loader.exe") Script 1: MsgBox(0,'','i am script 2') Script 2 loader: MsgBox(0,'','i am script 2 loader') When script 1 told to execute Script 2 loader it executes Script 2 instead What am i doing wrong here ? Link to comment Share on other sites More sharing options...
enaiman Posted October 12, 2010 Share Posted October 12, 2010 I don't know what are you really trying to do because the snippets you posted have no other effect than confusing me. Everytime you have a path which contains a white space (or more) and you want to use that as an argument for an application/script ... you need to take extra precautions to have that path firmly enclosed between quotes because the white space can be seen as preceding a second argument and the command will fail. Pay attention at the way this path is used in the second script because the error is there. To test my advice - rename your exe to "amsn_loader.exe" and try again - I bet it will work. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
madasraka Posted October 12, 2010 Author Share Posted October 12, 2010 Everytime you have a path which contains a white space (or more) and you want to use that as an argument for an application/script ... you need to take extra precautions to have that path firmly enclosed between quotes because the white space can be seen as preceding a second argument and the command will fail.Wow i thought these precautions apply to command prompt and other console applications.Ok even if so, why script has no problem getting to "F:\Installed programs\aMSN\amsn.exe" which does have space but cant get to "F:\Installed programs\aMSN\aMSN Loader.exe" ?This is what confusing me.Your advice in fact did fix the problem for which i thank you, but the fact that above example is true isnt that a bug ? Link to comment Share on other sites More sharing options...
enaiman Posted October 12, 2010 Share Posted October 12, 2010 No, it is not a bug. I presume you were reading a part of the path from an ini file and adding something after that to have the whole command line. If you post your code I should be able to show you where the error was. If you don't mind having the new name (with undescore) then it works and you don't need to worry about it. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
madasraka Posted October 12, 2010 Author Share Posted October 12, 2010 (edited) No, it is not a bug. I presume you were reading a part of the path from an ini file and adding something after that to have the whole command line. If you post your code I should be able to show you where the error was. If you don't mind having the new name (with undescore) then it works and you don't need to worry about it. Dim $szDrive1, $szDir1, $szFName1, $szExt1 $GetPath1 = _PathSplit(IniRead (@ScriptDir & "\Settings.ini","Components","Path1",""), $szDrive1, $szDir1, $szFName1, $szExt1) $ReturnPath1 = _ArrayToString ($GetPath1,"",1,2) Run (IniRead (@ScriptDir & "\Settings.ini","Components","Path1",""),$ReturnPath1) INI [Components] Path1=F:\Installed programs\FireFox\FireFox loader.exe thats one example. This will execute firefox.exe instead of FireFox loader.exe that are located in same folder. I used _PathSplit (thanks to someone else here) to set executed scripts working directory to its location. Thanks for your help. Edited October 12, 2010 by madasraka Link to comment Share on other sites More sharing options...
Mison Posted October 12, 2010 Share Posted October 12, 2010 Try to enclose your path with "". Not tested, but theoretically should work. $ReturnPath1 = '"'&$ReturnPath1&'"' Hi ;) Link to comment Share on other sites More sharing options...
enaiman Posted October 12, 2010 Share Posted October 12, 2010 (edited) Your code should work - I can't see anything wrong in there if that is the content of your ini file. Anyway - try to add quotes before and after IniRead: Run ('"'&IniRead (@ScriptDir & "\Settings.ini","Components","Path1","")&'"',$ReturnPath1) See what happens - it should work this way - weird. Edited October 12, 2010 by enaiman SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
madasraka Posted October 12, 2010 Author Share Posted October 12, 2010 Anyway - try to add quotes before and after IniRead: Run ('"'&IniRead (@ScriptDir & "\Settings.ini","Components","Path1","")&'"',$ReturnPath1) See what happens - it should work this way - weird. And it does Thank you much sir 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