I was seeing if I could use python to delete a file upon reboot. I am only able to rename it at reboot, I can't figure out the syntax to set the destination to null. Below is what works to rename the file

import win32file
import win32api

win32file.MoveFileEx("test.txt", "test2.txt" , win32file.MOVEFILE_DELAY_UNTIL_REBOOT)

how can I set the destination to null, to delete upon reboot?

Recommended Answers

All 2 Replies

I used the method from win32api instead of win32file and this works

win32api.MoveFileEx("file", None, win32con.MOVEFILE_DELAY_UNTIL_REBOOT)

Great that you figured it out. I checked the win api help, and the only thing I came up with was a possible problem with the win api NULL and Python's None. It looks like there is no problem there!

Nice to see you still active with Python!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.