Use the Windows registry to replace files during startup

Source: Internet
Author: User
1. Why do I need to use the registry to replace files when starting the system?
Some files are monopolized by some services of the system. We cannot replace them directly during hot backup and hot recovery.
There are also some Program Open a file in exclusive access. Before the program exits, we cannot replace the file as usual.
In these cases, we can use the registry to record the files to be replaced and other related information, and replace them before the next boot and application startup.
2. Specific implementation methods
Remember to back up your registry before performing the following steps.
The following uses win32k in the directory c: \ temp. replace win32k in the system directory % SystemRoot % \ system32. the sys file is used as an example to describe how to use the registry to replace files at startup. You can replace any files in your windows system in this way. Of course, your windows should be able to start.
1. Start Registry Editor (regedit.exe );
2. Find the related key in the registry as follows:
HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Session Manager
3. In the Session Manager registry directory, create a value as follows ):
Value Name: pendingfilerenameoperations
Type (data type): reg_multi_sz (Multi-string value)
Value Data ):\?? \ C: \ temp \ win32k. sys! \?? \ C: \ winnt \ system32 \ win32k. sys
Note that you must enter the value in two rows (one row will be displayed in the registry after the value is filled), and that "!" It must start with the second line.
This expression uses the file in the preceding path to replace the file in the following path.
4. Exit the Registry Editor;
5. restart the system.
After windows is restarted, if the second file exists, the content of the first file is replaced with the second file. The file name of the Second file remains unchanged and the first file is deleted; if there is no corresponding second file in the system, the system will automatically create a file with the same name as the second file, and then copy the content in the first file. After the replacement is completed, the system automatically clears the pendingfilerenameoperations value added to the Registry.
To replace multiple files in batches, you only need to add the information of the files to be replaced in the Registry variable value data in the form of the above value data. For example:
\?? \ C: \ Test2 \ test2.txt! \?? \ C: \ test1 \ test1.txt \?? \ C: \ Test2 \ test22.txt! \?? \ C: \ test1 \ test11.txt

if an error occurs when you replace the file with the above method, check whether the expression in step 3 is correct.
You can also use the mv.exe tool provided by windows, or download and use the inuse.exe tool. For more information about how to use these tools, see the help description.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.