Two Methods: Registry and movefileex Function
The Registry is in HKEY_LOCAL_MACHINE/system/CurrentControlSet/control/Session Manager.
Lower
Import the following content to the Registry and open the Registry to edit the key.
The key value is
/?? /C:/perflog/readme2.txt
! /?? /C:/test1.txt
The first action is the source file, and the second action is the object name of the target location to be moved. If you replace the system file, you need to use the allowprotectedrenames key.
Indows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE/system/CurrentControlSet/control/Session Manager]
"Pendingfilerenameoperations" = hex (7): 5C, 00, 3f, 00, 3f, 00, 5C, 00,43, 00, 3A, 00, 5C, 00 ,/
, 4C, 00, 6f, 00, 00, 5C, 00, 6d ,/
, 65, 00, 2e, 78, 00, 00, 21, 00, 5C, 00, 3f, 00, 3f, 00, 5C, 00 ,/
, 00, 3A, 00, 5C, 65 ,/
00, 00
[HKEY_LOCAL_MACHINE/system/CurrentControlSet/control/Session Manager]
"Allowprotectedrenames" = DWORD: 00000001
Type 2: Use the movefileex function, which is more suitable for the automatic upgrade mode. Multiple files can be replaced, which is easy to operate.
Description of this function
C Declaration function prototype:
Bool movefileex (maid, // file name maid lpnewfilename, // new file name DWORD dwflags // move options );
Parameter description:
Lpexistingfilename: an existing file or folder string pointer lpnewfilename, a non-existing file or folder string pointer dwflags, one or more of the following constants: movefile_copy_allowed move to a different volume, copy the file and delete the original file. The movefile_create_hardlink system is retained for future use. The movefile_delay_until_reboot mobile operation is officially started the next time the system restarts. If the source file movefile_fail_if_not_trackable is a link file but the file cannot be tracked after it is moved, the function execution fails. If the target file is in a fat format file system, the above situation can occur. This parameter does not support the NT System. (I want to talk about the mobile shortcut. If the target file specified by the shortcut does not exist or cannot be located, the operation fails. Because there is no time for testing, it is understood for the moment .) Replace movefile_replace_existing if the target file exists. The movefile_write_through flag allows the function to return the result after the file is moved. Otherwise, the function returns the result directly after the file is moved. If the movefile_delay_until_reboot flag is set, the movefile_write_through flag is ignored.