How does Windows remove locked files in the next reboot when you uninstall a program?

邮差的信 提交于 2019-12-07 16:40:52

问题


How does Windows remove locked files in the next reboot when you uninstall a program? Maybe with some kind of scheduled process?


回答1:


The uninstall process uses MoveFileEx with the MOVEFILE_DELAY_UNTIL_REBOOT flag set, which indicates that the operation shouldn't occur until reboot. Leaving the lpNewFileName parameter NULL indicates the file should be deleted:

If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT and lpNewFileName is NULL, MoveFileEx registers the lpExistingFileName file to be deleted when the system restarts. If lpExistingFileName refers to a directory, the system removes the directory at restart only if the directory is empty.

The info on MOVEFILE_DELAY_UNTIL_REBOOT says:

MOVEFILE_DELAY_UNTIL_REBOOT

The system does not move the file until the operating system is restarted. The system moves the file immediately after AUTOCHK is executed, but before creating any paging files. Consequently, this parameter enables the function to delete paging files from previous startups

The above function writes an entry to the registry which is automatically processed during startup:

The function stores the locations of the files to be renamed at restart in the following registry value:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations



来源:https://stackoverflow.com/questions/21641006/how-does-windows-remove-locked-files-in-the-next-reboot-when-you-uninstall-a-pro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!