macvoo Posted September 10, 2013 Posted September 10, 2013 (edited) Dear AutoIT Community, I am working a few days with autoIT and have one problem I can't solve although I had some hours of research and hope that you can help me on this topic. I have to start an .exe automatically that needs an .ini file to start appropriate (the ini file is including parameters like "host:aston3.com" and "port:9999") the windows shortcut & the run comnmand is the following and works fine: "C:\Program Files\AutoIt3\Au3Info.exe" -ini:.\ini\theIniFile.ini if i execute the same statement with Run or ShellExecute in AutoIT Script, the ini file gets ignored or it results in an fatal-error (because the Run-Statment dont know what to do with "-ini:" part) I also tried some variations of the command that i could think of(playing around with " and ', include the whole path of the ini-file and some others) my last try was to give parameters with ShellExecute like this, but the statement itself fails: (at least i managed to read the parameters out of the inifiles and print them in a msgboxy) ShellExecute("C:\Program Files\AutoIt3\Au3Info.exe", "aston3.com 9999") ShellExecute("C:\Program Files\AutoIt3\Au3Info.exe", "host:aston3.com port:9999") ShellExecute("C:\Program Files\AutoIt3\Au3Info.exe", "aston3.com", "9999") ShellExecute("C:\Program Files\AutoIt3\Au3Info.exe", "'aston3.com' '9999'") I would be very happy for any kind of input on this topic. Kind Regards, macvoo Edited September 10, 2013 by macvoo
abberration Posted September 10, 2013 Posted September 10, 2013 (edited) What you want to do is not going to work. You are exactly right in that the run statement does not know what to do with a "-ini" parameter. You must first read what is in the ini file and use that information as parameters. Example: $parameter1 = IniRead("theIniFile.ini", "Site", "Value", "") $parameter2 = IniRead("theIniFile.ini", "Port", "Value", "") ShellExecute("C:\Program Files\AutoIt3\Au3Info.exe, $parameter1 & " " & $parameter2) ; or Run("C:\Program Files\AutoIt3\Au3Info.exe " & $parameter1 & " " & $parameter2) Edited September 10, 2013 by abberration Easy MP3 | Software Installer | Password Manager
DW1 Posted September 10, 2013 Posted September 10, 2013 @macvoo, You are not being clear in what you need to accomplish. Is the executable being called that needs to point to an ini file, a compiled autoit script? If so, then yes, you can accept anything you want as a parameter and handle it accordingly. Is the executable something that already reads an ini file, but it is giving you an error stating that it doesn't see it, perhaps because you didn't set the proper working directory? Give us details and we can help. If you are just trying to call an executable from your own script based on the contents of your own ini file, then the solution abberration provided is fine ( after fixing the quotes ). AutoIt3 Online Help
Solution TheSaint Posted September 11, 2013 Solution Posted September 11, 2013 (edited) the windows shortcut & the run comnmand is the following and works fine: "C:\Program Files\AutoIt3\Au3Info.exe" -ini:.\ini\theIniFile.ini Are you saying that exact statement in a shortcut works fine and does as expected? I'm not familiar with any switches for Au3Info.exe, but if -ini: is one, then we really need to see the code you used for both the Run command and ShellExecute. Therein could lie your problem? i.e. Run("C:Program FilesAutoIt3Au3Info.exe -ini:.initheIniFile.ini") or similar. Note the quotes. As has been suggested, you may also need to provide the working directory (path of ini file). Edited September 11, 2013 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
macvoo Posted September 11, 2013 Author Posted September 11, 2013 (edited) wow i'm amazed about your quick responses! first of all sorry for not beeing clear, at the end of the post there is a very simple workaround for my problem, i wouldn't have thought of without you, thanks!!! What you want to do is not going to work. You are exactly right in that the run statement does not know what to do with a "-ini" parameter. You must first read what is in the ini file and use that information as parameters. Example: $parameter1 = IniRead("theIniFile.ini", "Site", "Value", "") $parameter2 = IniRead("theIniFile.ini", "Port", "Value", "") ShellExecute("C:\Program Files\AutoIt3\Au3Info.exe, $parameter1 & " " & $parameter2) ; or Run("C:\Program Files\AutoIt3\Au3Info.exe " & $parameter1 & " " & $parameter2) hmm i tried this out right now, but in my case it didn't help me =( ShellExecute("C:\Program Files\AutoIt3\Au3Info.exe", $parameter1 & " " & $parameter2) also with 1 parameter (just for testing to fillout 1 of the 2 values) both parameters stays empty. Maybe I am wrong about the needed connection string of the SW ShellExecute("C:\Program Files\AutoIt3\Au3Info.exe", $parameter1) @macvoo, You are not being clear in what you need to accomplish. Is the executable being called that needs to point to an ini file, a compiled autoit script? the .exe file is not an autoIt Script, it is a banking software. this software needs some parameters to start. otherwise an error occurs like: "xy couldn't be started, the connection string is wrong or has empty parameter. host:empty, port:empty" if you click on the windows shortcut then the shortcut executes the .exe and calls the .ini file somehow (i didn't managed to find out how the .exe and the .ini exchanges the parameters in the windows shortcut.) If so, then yes, you can accept anything you want as a parameter and handle it accordingly. Is the executable something that already reads an ini file, but it is giving you an error stating that it doesn't see it, perhaps because you didn't set the proper working directory? Give us details and we can help. If you are just trying to call an executable from your own script based on the contents of your own ini file, then the solution abberration provided is fine ( after fixing the quotes ). I also tried that one, if thats what you mean by setting the working directory: Run('"C:Program FilesAutoIt3Au3Info.exe" -ini:C:Program FilesAutoIt3initheIniFile.ini') Are you saying that exact statement in a shortcut works fine and does as expected? I'm not familiar with any switches for Au3Info.exe, but if -ini: is one, then we really need to see the code you used for both the Run command and ShellExecute. Therein could lie your problem? i.e. Run("C:Program FilesAutoIt3Au3Info.exe -ini:.initheIniFile.ini") or similar. Note the quotes. As has been suggested, you may also need to provide the working directory (path of ini file). yes it does work with the shortcut. and actually you gave me an hint of a workaround with that! I simply call my windows shortcut with the script so I don't have to start the SW over an Run/Shellexecute Statement (even though it's not a nice solution, its fine for my needs..) I am sorry for any kind of blur in my question... and thanks a lot for your ambitious help!! Edited September 11, 2013 by macvoo
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