My Software dll patches are not updated on windows 10

-1

I have an existing files on windows 10 (dll,.exe,.msi) which I am trying to update by sending some patches. But the issue is during update if any of the file is being used, and I am trying to update that file by replacing it with new updated file , windows is prompting a delete file popup for the existing file.If we say yes it is showing as successfully deleted but it is not deleted till the last user releases the file .After that new updated file is not replaced in that place.

Edit: The poster has indicated in a comment that his problem relates to registered DLLs.

sams

Posted 2018-06-01T18:56:42.887

Reputation: 9

" I am trying to update by sending some patches" what patches, please explain. – Moab – 2018-06-01T19:09:57.573

How are you pushing these updates out exactly? – Ramhound – 2018-06-01T20:04:29.387

patches of my software - bunch of .exes push to client – sams – 2018-06-01T20:30:06.840

Answers

2

How do I replace an in use DLL?

Dynamic-Link Library Updates

It is sometimes necessary to replace a DLL with a newer version. Before replacing a DLL, perform a version check to ensure that you are replacing an older version with a newer version. It is possible to replace a DLL that is in use. The method you use to replace DLLs that are in use depends on the operating system you are using. On Windows XP and later, applications should use Isolated Applications and Side-by-side Assemblies.

It is not necessary to restart the computer if you perform the following steps:

  • Use the MoveFileEx function to rename the DLL being replaced. Do not specify MOVEFILE_COPY_ALLOWED, and make sure the renamed file is on the same volume that contains the original file. You could also simply rename the file in the same directory by giving it a different extension.
  • Copy the new DLL to the directory that contains the renamed DLL. All applications will now use the new DLL.
  • Use MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT to delete the renamed DLL.

Before you make this replacement, applications will use the original DLL until it is unloaded. After you make the replacement, applications will use the new DLL. When you write a DLL, you must be careful to ensure that it is prepared for this situation, especially if the DLL maintains global state information or communicates with other services. If the DLL is not prepared for a change in global state information or communication protocols, updating the DLL will require you to restart the computer to ensure that all applications are using the same version of the DLL.

Source Dynamic-Link Library Updates (Windows)


How to replace in-use files at Windows restart

This article describes another method you can use to replace files that are in use by Windows. This method uses the registry to replace a file at startup, before the file is accessed by Windows.

The following steps demonstrate how to replace the Win32k.sys file in the %SystemRoot%\System32 folder with the Win32k.sys file located in the C:\Temp folder. You can use variations of this method to replace any file if your installation of Windows is bootable.

  1. Start Registry Editor (Regedt32.exe).
  2. Locate the following key in the Windows registry:
    • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
  3. Create a new value by using the following information:
    • Value name: PendingFileRenameOperations
    • Data type : REG_MULTI_SZ
    • Value data: \??\c:\temp\win32k.sys !\??\c:\winnt\system32\win32k.sys
    • Note that the value data is typed on two separate lines.
  4. Quit Registry Editor.
  5. Restart the computer.

Source How to replace in-use files at Windows restart

DavidPostill

Posted 2018-06-01T18:56:42.887

Reputation: 118 938

This does not work for registered dlls. – harrymc – 2018-06-02T08:40:47.390

@harrymc Then the user should update his question, which makes no mention of registered DLLs. – DavidPostill – 2018-06-02T14:57:45.807

It is in the comments, but I did it now for him. – harrymc – 2018-06-02T17:07:21.357

1

The correct way to replace a DLL is :

  • Rename the DLL file
  • Store the new DLL file under the correct name
  • The renamed file becomes deletable when it's no longer in use.

For registered DLLs, you must un-register them in-place and register the new version. The un-registration process (when done with an installer) will detect in-use DLLs and warn you that you need to reboot. Plus, this also means that the DLLs can't be loaded (once unregistered) while you are copying new files or registering new files.

You should therefore distribute your patch as an installer. For example you could use the free Inno Setup. When I used it last, you needed to set the attributes of the DLLs to be installed to do registration and re-registration. The process will then be automatic with no special programming required on your side.

If you cannot distribute your patch as an installer, you should set it as run-once on startup and require a reboot. For more information see the article Run a Program Only Once when you Boot Into Windows, which requires some registry work.

harrymc

Posted 2018-06-01T18:56:42.887

Reputation: 306 093

harrymc we are talking about the registered dll's – sams – 2018-06-01T20:30:58.357

@sams You made no mention these DLLs were registered. Those only apply to COM libraries anyways. – Ramhound – 2018-06-01T21:12:09.900

@sams: I added a part for registered DLLs. – harrymc – 2018-06-02T08:39:45.870