> inuse c:\foo.dll c:\windows\system32\foo.dll
In this example, the file c:\windows\system32\foo.dll will be replaced by c:\foo.dll after the system reboots.
' This code executes the inuse command to replace a file. ' ------ SCRIPT CONFIGURATION ------ ' Modify the command string as necessary strCmdString = "inuse.exe c:\foo.dll c:\windows\system32\foo.dll" ' ------ END CONFIGURATION --------- set objWshShell = CreateObject("WScript.Shell") set objExec = objWshShell.Exec(strCmdString) do while not objExec.StdErr.AtEndOfStream WScript.Echo objExec.StdErr.ReadLine( ) loop do while not objExec.StdOut.AtEndOfStream WScript.Echo objExec.StdOut.ReadLine( ) loop
Ever needed to replace a DLL or other file, but couldn't because the system said it was in use? With the inuse utility, you can replace files that are currently locked. Simply pass inuse the location of the new version of the file and the location of the currently locked file, and on reboot, the file will be overwritten. inuse works by setting a registry value that Windows looks at when booting up to determine if there are any pending file renames. For more information on the specific key and value, see MS KB 181345.
On Windows 2000, inuse is a Resource Kit tool and therefore not officially supported by Microsoft, so use it at your own risk. On Windows Server 2003, the command is part of the default installation and is supported. Also keep in mind that there is no "undo" function. So once you've overwritten a file, unless you made a copy of the original previously, you won't be able to revert back to it.