PDA

View Full Version : Please Help With File.Run I have Drawn a Complet Blank ...


whirl
02-12-2005, 03:17 PM
Hello.

I have been trying for ages now and I have come to a dead end so I am turning to you chaps for help.

On my startup action, i am trying to uninstall the previous version of my program before installing the new one.

I know that the uninstall string is

"C:\WINDOWS\myapp\uninstall.exe" "/U:C:\Program Files\myapp\irunin.xml"

but I just cannot figure how to do it with File.Run

Any help would be appreciated pus an example would be even better so I can save it for further use.

Regards

Brett
02-12-2005, 03:22 PM
Something like:

File.Run(_WindowsFolder.."\\myapp\\uninstall.exe","/U:C:\Program Files\myapp\irunin.xml");

should work.

whirl
02-12-2005, 03:29 PM
Hi

When I run that i get a message box saying Invalid Uninstall Control File

Any Ideas brett

Absynthe
02-12-2005, 05:21 PM
Shouldn't that be

File.Run(_WindowsFolder.."\\myapp\\uninstall.exe","/U:C:\\Program Files\\myapp\\irunin.xml");

whirl
02-12-2005, 05:26 PM
Well this one really has me beat.... :huh

Any other suggestions

:huh

Absynthe
02-12-2005, 05:42 PM
have you verified the existence of irunin.xml in the myapp folder?

whirl
02-12-2005, 05:46 PM
Yes, if i run it from a dos cmd line its fine

:huh

whirl
02-12-2005, 06:05 PM
I have just noticed that my folder where my app is has spaces

c:\program files\my app\bla

would this have anything to do with it ??

Absynthe
02-12-2005, 06:26 PM
Yes, that would be why it is not working

[edit] Let me rephrase that, if you app folder name has spaces but your command line doesn't then that is why it is not working.

whirl
02-12-2005, 06:29 PM
Can you tell me how or if it can be fixed ?

Brett
02-12-2005, 07:26 PM
Shouldn't that be

File.Run(_WindowsFolder.."\\myapp\\uninstall.exe","/U:C:\\Program Files\\myapp\\irunin.xml");

RIGHT! Try that. It should work. I forgot to escape the quotes in the second part. :wow

csd214
02-13-2005, 04:20 AM
whirl, I think you still will have the error message "Invalid Uninstall Control File".

The arguments to File.Run must be:

/U:"C:\\Program Files\\My App\\irunin.xml"

and has to be enclosed in quotes (string value), but you can't use:
"/U:"C:\\Program Files\\My App\\irunin.xml""

Either you have to escape the double quotes within the string:

"/U:\"\"D:\\Program Files\\plusAVSKRIV\\PD_Avinstall.xml\""

or you have to combine with single quotes:

'/U:"C:\\Program Files\\My App\\irunin.xml"'

I have attached a sample program; you can easily try the various arguments. (The default file names may be adjusted in 'On Startup'.)

I have worked a bit with the uninstall command by reason of
i) To be able to start an uninstall from a setup executable (your case)
ii) To be able to have the uninstall shortcut in a shortcut subfolder (then I have to create the shortcut manually) because "Uninstall" would be the first option on the Windows start menu when you live outside an English-spoken country (due to the Windows shortcut sort order).

whirl
02-13-2005, 05:08 AM
Hello

Thank you very much, with your example, I have managed to get it to uninstall.

I didn't know about using the single quotes ' '

Thankyou for taking thre time to show me how to achieve this.

All the best.

csd214
02-13-2005, 05:27 AM
No problems; in fact it is a pleasure to return something to the I.R. Forums. I have learned a lot from this source.

BTW, the combination of double/single quotes is a nice way to make the code more readable - in any language! The double quotes with escaped double quotes require that you have had your morning coffee… :o

csd214
02-17-2005, 02:05 PM
On my startup action, i am trying to uninstall the previous version of my program before installing the new one

I ran into whirl's scenario before I expected. I thought that the easiest way was to read the 'UninstallString' in the Registry, rather the constructing the commandline as explained in postcount #12. A query might give results like this:

From SUF60:
C:\WINDOWS\iun6002.exe "C:\CompanyName\ProductName\irunin.ini"

From SUF70:
"C:\WINDOWS\SUF70 Program Flow\uninstall.exe" "/U:C:\Program Files\SUF70 Program Flow\Uninstall\uninstall.xml"

These strings can be entered at command prompt to start the uninstaller.

I intended to use
File.Run(sCommand, sArguments, "", SW_SHOWNORMAL, true);
where
sCommand = "C:\WINDOWS\SUF70 Program Flow\uninstall.exe"
sArguments = "/U:C:\Program Files\SUF70 Program Flow\Uninstall\uninstall.xml"

Naturally I had to replace the single backslash with double backslashes in both variables. In addition I had to remove the quotes in the command (sCommand = C:\\WINDOWS\\SUF70 Program Flow\\uninstall.exe)

I didn't expect this should work due to the spaces in the path, but the fact is: It works; and it is the only syntax that is usable. If I use sCommand = " C:\\WINDOWS\\SUF70 Program Flow\\uninstall.exe" I'll get Error 1013 File execution failed.

I try to understand and my question is:

Does File.Run() automatically add double quotes to the "Filename" = "(string) The path to the executable (.exe) file."?

csd214
02-21-2005, 06:01 AM
File.Run() does neither add or remove quotes, but the 'FileName' argument has to be a string value. If you set sFileName = "C:\\WINDOWS\\SUF70 Program Flow\\uninstall.exe"; you have a string value you can use in File.Run(sFileName, "", .....).

The code sFileName = C:\\WINDOWS\\SUF70 Program Flow\\uninstall.exe; wouldn't create a string value. sFileName = "\"C:\\WINDOWS\\SUF70 Program Flow\\uninstall.exe\""; gives indeed a string value, but Windows wouldn't recognize this as a valid command. Windows should report:
'""C:\WINDOWS\SUF70' is not recognized as an internal or external command, operable program or batch file.

In my answer to whirl I said:
The arguments to File.Run must be: /U:"C:\\Program Files\\My App\\irunin.xml"

That's the syntax from the Start Menu Uninstall shortcut. The Control Panel (or the Registry) uses "/U:C:\Program Files\SUF70 Program Flow\Uninstall\uninstall.xml" (my previous post). The simplest way to start the uninstaller is to read the UninstallString in the registry:

"C:\WINDOWS\SUF70 Program Flow\uninstall.exe" "/U:C:\Program Files\SUF70 Program Flow\Uninstall\uninstall.xml"

Use the red part as the 'FileName' and the blue part as the 'Args'; but remember the escaped backslash.

Tek
02-24-2005, 02:07 PM
This is the silent uninstall code that I put together to remove the previous version just before the new one gets installed.

Just as a note... you mentioned that you want the previous version uninstalled when your installer is started. What I do is to put the uninstall just before the new one gets installed so that if the user wishes to cancel before the new one is installed then the old version is still there. I have this code on my Pre-Install tab.

Heres the code:


-- Check for the existence of a Setup Factory installation and silently uninstall first
IRUninstXMLExist = File.DoesExist("%AppFolder%".."\\".."irunin.xml");
if IRUninstXMLExist then
result = File.Run("C:\\WINDOWS\\My Program\\uninstall.exe", "\"/U:C:\\Program Files\\My Program\\irunin.xml\" /S", "C:\\WINDOWS\\My Program", SW_MINIMIZE, true);
end


This was tricky for me too but I eventually got it working.

csd214
02-24-2005, 03:04 PM
Silent uninstall! Why didn't' I think of that? Thank you. It makes the GUI more understandable.

The "IRUninstXML" may have different names and different locations. Still I think the easiest way is to read the Registry:

local sRegKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Unin stall\\"..sUniqueKey;
local sUiCmd = Registry.GetValue(HKEY_LOCAL_MACHINE, sRegKey, "UninstallString", true);

In another thread I have spoken for "housekeeping"; meaning to delete the Uninstaller on reboot. What happens: The setup runs uninstall. Uninstall deletes uninstall.exe. After the reboot the user is not able to uninstall the newly install app? (The same happens with a manual uninstall and then an install). Housekeeping is dangerous (especially to men).

But I don't like that each app shall have a Windows subdir with its own uninstaller. I don't need the uninstaller for 'Setup Factory 7.0 Trial' anymore. (I frequently burn image of the C-drive to CD's. I don’t' want more CDs then necessary). I have to think. Maybe _WindowsFolder\_IR_ProductID could be a suitable folder and use file version of SUF70 as part of the uninstaller file name?

BTW, when you use DeleteOnReboot/MoveOnReboot; where's the info stored? Is it possible to recall the Delete/Move on reboot?

SUF6NEWBIE
02-24-2005, 11:59 PM
Another trick to get around 'spaces' in Paths in general when it comes to
using file.run with run comms is take adavantage of converting path strings
to the shortname (file.getshortname), using this method helps prevent any 256 char limitations and by its nature removes any spaces in path strings..

Very handy for some of those tricky run comms...

Registry: where does 'on reboot' actions live..

basically have a look in HKLM...run or runonce or 'pendingfilerenameoperations'
or look in HKCU for the Run keys..some may need expanding..

HTH

csd214
03-01-2005, 07:42 AM
The new command Screen.End() should be appropriate in the described scenario.

Has anybody ever tried Screen.End()? (It is not possible to use this action; look up my post about reserved keywords (http://www.indigorose.com/forums/showthread.php?t=10516).)