Replacing Windows System Files Live

Topic-Windows

Recently I had the need to replace Windows system files manually, while Windows is running.  For those of you have tried this in the past you may know that it is easier said than done.  Windows protects these files and/or they may be in use and then the error you get is “Access Denied”.

After searching high and low for a solution I stumbled across a StackOverflow page that provided the solution – http://stackoverflow.com/questions/4443578/how-to-replace-locked-dll-was-inuse

Copying system dlls on Windows 7 (and Vista) is described in System File Checker tool article (in “Step2: If the System File Checker tool cannot repair a file”).

Here is a quick (almost copy&paste) solution to use in a batchfile:

REM you will need to change this :-) - the SOURCE and the DESTINATION
SET tmpset_SOURCE=c:\Temp\fileyouwanttoreplace.dll
SET tmpset_DEST=c:\Windows\SysWOW64\fileyouwanttoreplace.dll

REM copy and paste this straight to cmd:
takeown /f %tmpset_DEST%
icacls %tmpset_DEST% /GRANT %USERNAME%:F
copy %tmpset_SOURCE% %tmpset_DEST%

For those of you who want to understand what is happening above, lets break it down.

  1. Firstly the Source and the Destination variables are being set
  2. The “takeown” command is taking ownership of the destination file by force
  3. The “icacls” command is setting the permission of the destination file to the currently logged on user
  4. The copy command

It worked like a charm and this is something you want to keep in your “Admins Toolkit” 🙂

 

MadMike posted at 2014-2-20 Category: Windows / WHS

Leave a Reply

(Ctrl + Enter)