3

We use Inno Setup(version 5.4.2) as the packaging tool to generate our installer. While upgrading our software from older version to current version, we try to overwrite existing binaries/drivers. This is often leading to issues as some monitoring software like 'HP ArcSight Logger/Connector', 'SplunkUniversalForwarder' etc. are holding file handles on our binaries and casuing overwrite to fail. Our installer shows beolow popup message on encountering this issue each time.

"C:\Windows\System32\drivers\xxx.sys

An error occurred while trying to replace the existing file: DeleteFile failed; code 5. Access is denied.

Click Retry to try again, Ignore to skip this file(not recommended), or Abort to cancel installation"

Interestingly, even after above getting above pop-up, we were able to rename xxx.sys to xxx.sys.old manully. We used to suggest cusotmers to rename xxx.sys to xxx.sys.old and 'Retry' the installation. After renaming, upgrade used to complete without any issues.

Questions

1) Is it possible to rename xxx.sys through program always, when we hit this issue.

2) Any process to reproduce the DeleteFile failed; code 5 issue?

user1752602
  • 423
  • 6
  • 19
  • Installing drivers is complex and best left to dedicated helpers. [See this previous question.](http://stackoverflow.com/questions/8864549/inno-setup-install-drivers-with-rundll32-or-dpinst) – Miral Jul 17 '13 at 21:59

1 Answers1

2

Using the installer you can rename the existing file and install the new file using the correct file name with help from the windows registry.

Remember to ask the user to reboot their computer to complete the install.

Another option would be to either use the installer to rename the file and again using the window's registry to delete the unneeded file.

Window's registry allows you to delete or rename files on reboot as part of an install.

Reference to use of PendingFileRenameOperations: http://support.microsoft.com/kb/181345

Example to rename from microsoft support: The syntax used is (without quotes):
"\??\source file !\??\target file"

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
Value name: PendingFileRenameOperations Data type : REG_MULTI_SZ
Value data: \??\c:\temp\win32k.sys !\??\c:\winnt\system32\win32k.s

The same command can be used to delete a file as well although requires the use of nulls. http://www.pcreview.co.uk/forums/pendingfilerenameoperations-delete-file-t1715654.html

Same example used to delete a file: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
Value name: PendingFileRenameOperations Data type : REG_MULTI_SZ
Value data: \??\c:\temp\win32k.sys\0\0\0

I hope this helps you!

Joshua Briefman
  • 3,783
  • 2
  • 22
  • 33
  • Now we are renaming xxx.sys to xxx.sys.old before upgrade using renamefile. My question is, is it possible to rename xxx.sys through program always, when we hit DeleteFile failed; code 5 issue. – user1752602 Jul 16 '13 at 06:34
  • The above registry entry will also work to delete the in use file (as restartreplace would, however I saw no mention on using that command to delete a file) when the computer restarts so that it does not remain in the system as an unused file. As the original poster indicated they are unable to delete the file while it is in use (during the install process), and thus must be deleted after reboot.
    – Joshua Briefman Jul 16 '13 at 07:10
  • With only "restartreplace" the user MUST reboot their system prior to the use the software, the old file will retain it's current name until reboot. By renaming the file during install (using renamefile) and using either (deleteafterinstall) or the registry to delete the old file, the user will not need to reboot to use the software. Both are valid options however. – Joshua Briefman Jul 16 '13 at 07:19
  • Correction, "deleteafterinstall" would not work. One must use the registry to perform a delete on reboot. I could find no mention of using "restartreplace" to do the same. – Joshua Briefman Jul 16 '13 at 07:26
  • 1
    You can do it from `[Code]` via the [`RestartReplace` support function](http://jrsoftware.org/ishelp/topic_isxfunc_restartreplace.htm). – Miral Jul 17 '13 at 21:58