Delete everything that resides in Download folder after Chrome browser is closed?

I’m trying to delete everything that is in Download folder once Chrome browser is closed. The use case is for a public PC, which is why I need the feature. I am doing it in a Chrome extension. Currently, I can detect chrome close event using:

I tried chrome.downloads.removeFile(id, callback) and it works. But it depends on the download history in Chrome to retrieve the ids for removal. If the user clear the download history, this function won’t work and the files are not deleted. So I need something else.

I thought of sending a message to run a .cmd command to delete files in Download folder but I don’t understand how it works after reading the tutorial.

Is there anyone who can help share some other approach which I can use in this case? Thanks!

Chrome extension – using the filesystem API

The filesystem API cannot be used by unpacked extensions, which is awfully great for development.

But then the real surprise came when I realized I can’t use it also with my extension packed, because Chrome tells me it cannot find it in the store and is thus greyed out.

Is there any way to actually develop with the filesystem API then?

My goal, in case this is the wrong direction in the first place, is to write some text to a file when some events in the browser happen. The file should be rewritten, rather than creating a new file, which is why I can’t use the downloads API.

Is there any way out of this conundrum?