PDA

View Full Version : Problem running File.Run


casman
03-22-2006, 06:50 AM
Hi SF7 forum.

I am currently having a problem with the File.Run command in SF7.

Basically, when the generated setup program is run, I want to execute an existing program to perform some actions prior to the installation continuing.

When I run it manually it works fine, but if I run it via File.Run, it always fails with 'File Execution Failed'.

At first I tried the following code:

result = File.Run(SessionVar.Expand("%AppFolder%\\TP Systray Remover.exe"), "", "", SW_MINIMIZE, true);

And it tried to run a program called TP instead, so I assumed the spaces were the problem.

I then tried the following code:

prog2run = SessionVar.Expand("%AppFolder%\\TP Systray Remover.exe");
result = File.Run("prog2run", "", "", SW_MINIMIZE, true);

I have checked the value of prog2run in a debug window and it is correct, however, it always fails to run.

Any guidance would be greatly appreciated.

Thanks in advance.

I am running SF7.0.5.1

Regards,
Casman.

Eagle
03-22-2006, 08:30 AM
rename your the project 'source file' to this: TP_Systray_Remover.exe

(or rename the executable to something without any spaces)

Adam
03-22-2006, 10:14 AM
casman,

At what point in the install are you calling this file? Keep in mind that if you are going to reference a file that is being installed then it has to be done After the files are installed.

Another good way to debug is hard code the path to the file in the File.Run action. Once you get it working with a hard coded value then get it working with the variable.

Adam Kapilik.

TJS
03-22-2006, 10:25 AM
You could also take a crack at calling your executable using the Shell.Execute() action instead of File.Run()...

casman
03-22-2006, 09:17 PM
Hello all.

Thank you for the responses.

To Eagle. Unfortunately I cannot rename the executable name as it is used in a number of applications.

To TJS, I'll give this a go.

To Adam.

The setup is actually used to Install and Update the application. If the application is installed, then my setup needs to check if a program is running in the systray. If it is, then I was trying to use the File.Run to run my program to remove the offending program from the systray prior to the Update.

That's when I ran into this problem.

I issue the File.Run on a 'Ready To Install' just prior to the 'Next' button being hit, so the systray entry is removed prior to the install actually starting to overwrite the executables.

Regards,
Chris Balakas

casman
03-23-2006, 04:01 PM
Thank you all for your suggestions.

I tried using Shell.Execute and it has solved my problem.

Regards,
Casman.

Jason Pate
03-24-2006, 02:48 PM
result = File.Run(SessionVar.Expand("%AppFolder%\\TP Systray Remover.exe"), "", "", SW_MINIMIZE, true);

I think your problem is you need "quotes" because of the space in the file name.

Try:
result = File.Run(SessionVar.Expand('"%AppFolder%\\TP Systray Remover.exe"'), "", "", SW_MINIMIZE, true);

casman
03-28-2006, 05:06 AM
Hi Jason.

I tried your code:

result = File.Run(SessionVar.Expand('"%AppFolder%\\TP Systray Remover.exe"'), "", "", SW_MINIMIZE, true);

This seems to have solved my problem. I can now run the program, wait for it to complete and then continue the setup.

I have not seen the technique used whereby you encircle the string in both single and double quotes.

Thanks for your help.

Regards,
Casman.

Jason Pate
03-28-2006, 09:49 AM
Sweet, Windows usually requires quotes in any path that has spaces, and it can easly be over looked. Good luck.

TJS
03-28-2006, 09:59 AM
Funny... would %20% have resolved the issue as well???

TJS
03-28-2006, 10:02 AM
DOS appreviation should work too:

\\TPSyst~1.exe

Jason Pate
03-28-2006, 11:23 AM
Never Tried either only have used quotes I guess sticking with what I know that works. And with scripting I like to be spectific. But not a bad idea.