Page 1 of 1
Run Program error
Posted: Sat Jul 16, 2005 2:37 pm
by EricB
I have one project that when the "Run Program" checkbox is checked at the end of the install, tries to run the program from the temp directory rather than from the "target directory". I have checked the code, and it is: $TARGETDIR$\\AppName.exe.
Any ideas on what I can do to fix this issue?
Thanks,
Eric
Posted: Sat Jul 16, 2005 4:54 pm
by sinan
I'd say call the SetCurrentDirectory WinAPI using the Call DLL Function plug-in and change the current directory to $TARGETDIR$.
Posted: Sat Jul 16, 2005 5:24 pm
by EricB
That is a workaround. What I want to know is why this works correctly in other setups, but not this one. From my understanding, using $TARGETDIR$\\AppName.exe should execute the program in $TARGETDIR$, not the temp directory the app is extracted to.
Is this not a correct understanding?
Thanks,
EricB
Posted: Sun Jul 17, 2005 4:30 am
by sinan
What leads you to believe that the program is running from the temp folder, as opposed to the target folder?
You're welcome to explore the situation with the CreateProcess API - it is what Run Program uses to execute your program.
Posted: Sun Jul 17, 2005 9:03 am
by EricB
When the program starts, it comes up with an error that it can't find the configuration file and the path it gives for the file is the temp directory. When I run it from the start menu, it works just fine (finds its config file) in the directory it was installed into.
Eric
Posted: Sun Jul 17, 2005 4:02 pm
by sinan
Why not use the Run Program As command, which lets you specify a startup directory? Maybe the problem is that the startup directory is wrong (temp), but the program is actually being launched from the correct folder. I believe this would explain what we're experiencing, in fact some users reported this, so we provided the Run Program As command, that lets you specify the startup directory, which would have to be $TARGETDIR$ in this case.
Posted: Sun Jul 17, 2005 5:40 pm
by EricB
I tried using the "Run Program As" function and get this code in the script window:
Run Program $TARGETDIR$\\AppName.exe , startup in folder $TARGETDIR$
When I click the "Finish" button, the .NET "Just-In-Time Debugging" dialog is shown with the following:
An exception 'System.TypeInitializationException' has occured in AppName.exe
To find out what "$TARGETDIR$" is set to, I inserted this code in the script window:
MessageBox: , $TARGETDIR$
When the message box is displayed, the text of the message box is:
D:\\Program Files\\\\My App Path
Can you tell me what is going on here?
Thanks,
Eric
Posted: Sun Jul 17, 2005 8:19 pm
by sinan
I cannot know why your application crashes when it is provided with a startup folder path.
If you are concerned about the double backslash, InstallAware automatically eliminates double backslashes in all path related functions before the function call executes.