Jump to content

script executing wrong file.


Recommended Posts

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

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

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

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

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 by madasraka
Link to comment
Share on other sites

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

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