Wednesday 26 February 2020

Using Node.js to clear files with admin (or current user permissions)?

I am currently working on an application in Electron that is designed for essentially running day-to-day operations for my users and as part of that I need to have options that users can click on to clean up files.A user can delete these files normally and I have the function that will delete the file in the folder however the issue comes up that there is insignificant privileges for my application to delete these files.Below is my code I'm currently using that would just clean up the users temp folder.function runMaintenance(app) { console.log(process.env.TEMP) if (app == 'app-main1') { const dir = process.env.TEMP; fs.readdir(dir, (err, files) => { if (err) throw err; for (const file of files) { fs.unlink(path.join(dir, file), err => { if (err) throw err; }); } }); }; }; fs and path are declared in my main.js file.I am not sure if there is a way to delete these files using the permissions of the current user or as admin.Is there any known way to do this?

Submitted February 26, 2020 at 02:17PM by akblais

No comments:

Post a Comment