Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Rename file during uninstall


10 replies to this topic

vaqueros

vaqueros
  • Full Members
  • 53 posts

Posted 24 January 2008 - 17:41

As part of my setup I create a backup of an existing file in the user's machine. I use the "MoveFile" table to rename "file.txt" to "file.bak" before my app's files are copied to the machine.

I want to then restore the file once my application is removed, in other words now I want to rename "file.bak" to "file.txt". This procedure needs to be done after my app's files have been removed.

I'm not sure how to do this, any help is greatly appreciated.


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 26 January 2008 - 15:35

A custom action might be your only option in this case.

vaqueros

vaqueros
  • Full Members
  • 53 posts

Posted 28 January 2008 - 19:50

OK, I will write a two line InstallScript function. I only want it to run when a particular feature is uninstalled. How do I specify this?

Thank you.

Edited by vaqueros, 28 January 2008 - 19:54.


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 30 January 2008 - 16:37

You could use a condition like this (see topic "Conditional Statement Syntax" in MSI help):
&FeatureName=2

vaqueros

vaqueros
  • Full Members
  • 53 posts

Posted 29 February 2008 - 20:39

I wrote the script and it works fine. However, I stumbled upon a new issue. The file to be renamed is a component of MS Word. If MS Word is open during the uninstall process the user will receive a warning saying:

"The following applications should be closed before continuing the installation:"

(See attached)

I am not able to find this dialog window in IS 2008 Pro. I would like to disable the "Ignore" button so the user is not allowed to continue before closing MS Word. If they do the "Rename" script will not work.

Where do I find this dialog? It is not the "FilesInUse" or "MsiRMFilesInUse" dialogs.

Attached Images

  • screen_inuse.jpg


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 05 March 2008 - 12:24

It's the MSI engine built-in Files in Use dialog, because the uninstall runs in Basic UI mode.

vaqueros

vaqueros
  • Full Members
  • 53 posts

Posted 05 March 2008 - 14:59

Can I modify this dialog? I want to disable the Ignore button. Can it be done?

Thanks.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 05 March 2008 - 18:23

No, you can't modify the msi engine's built in dialogs.

vaqueros

vaqueros
  • Full Members
  • 53 posts

Posted 05 March 2008 - 18:53

OK. I created an InstallScript function to check if file is locked. It displays a MessageBox if file is in use which notifies the user of the problem and aborts the uninstall process. This part is working fine.

However, the MSI engine built-in Files in Use dialog appears first, right after the unisntall process commences. If the user clicks Ignore the progress continues and my MessageBox is displayed The problem is it does not display on the foreground!!! It goes straight to the taskbar and the user might not even know it is there. How do I force it to appear on the foreground?

I'm trying using FindWindow but it is not able to "find" the window.

Thank you.

Edited by vaqueros, 05 March 2008 - 18:59.


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 06 March 2008 - 17:27

I'm not sure if that's possible, or how.

Instead of a custom action to display the error message, have you tried a type 19 custom action (display error message and abort)?

Or change your solution: Typically, if a file is locked and the user clicks "Ignore" the file operation is postponed until the reboot. In your cuatom action which copies the file you could call MoveFileEx
http://msdn2.microso...y/aa365240.aspx

vaqueros

vaqueros
  • Full Members
  • 53 posts

Posted 06 March 2008 - 18:01

Thanks for the reply Mr. Krueger. What I ended up doing was disabling the Remove button, this made the uninstall process run in regular Maintenance mode which allowed me to use InstallShield's File in Use dialog. I was then able to disable the Ignore button. Now the user MUST close the open application or exit setup.