Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

483
Views
Deleting a user account with files locked inside of it (Node.js)

I want to create a program that can delete user accounts even if they have files locked to administrators on the pc. I have it built so normal accounts are deleted, but it errors due to missing permissions if they have locked files. Is there a way I can either elevate my script, or bypass the restriction? Here is the current code to see how everything is formatted, if that helps.

const fs = require('fs')
process.on('uncaughtException', err => {
    console.log(err);
})
process.on('unhandledRejection', err => {
    console.log(err);
})
async function start() {
    try {
        var num = 0;
        for (var file of fs.readdirSync("C:/Users", () => { })) {
            if (!isNaN(Number(file))) {
                if (parseInt(file) <= 219999) {
                    fs.rmSync("C:/Users" + "/" + file, { recursive: true, force: true });
                    console.log("Removed User: " + file);
                    num += 1;
                }
            } else {
                console.log("Skipped " + file);
            }
        }
        console.log("\n\n" + "Removed " + num + " users!\n\nClosing window...")
        setTimeout(() => {
            process.kill();
        },2500)
    } catch (err) {
        console.log(err);
        console.log("\nMissing administor privileges!");
    }
}
start();
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!