Using WIndows 7 SR1

0

I work in a company that does net support for 20 different schools. While working on accounts I might log my "test" computer in 10 different domains in one day.

After a few days a login goes from 30 seconds to 5 minutes.

Then if I clear out all the profiles by right click computer, properties, advanced system settings, User Profile Settings, delete one by one.

Then clear their c:\user\jdoe folders.

Is there a script that can delete all the profiles, and all the network folders?

Like:

net user * /delete

or

for %%a in (***) do (
   net  user  %%a  /del
   rd  /s  /q  "C:\UserProfiles\%%a"
)

but I need to replace *** with each user.

Joshua

Posted 2016-03-03T17:01:21.870

Reputation: 9

1You might want to adjust the title, it seems to have nothing in common with the actual question. – Hennes – 2016-03-03T17:23:47.560

I have no idea what "Windows 7 SR 1" is – Ramhound – 2016-03-03T17:57:54.520

Possibly SP1??? – Moab – 2016-03-04T16:51:51.067

Answers

1

Is there a script that can delete all the profiles, and all the network folders?

You can user wmic useraccount get name to get a list of user names and for /f to process the list.

Warning:

  • Please review the following script carefully. I believe it does exactly what you ask for.
  • Not tested as I don't want to delete the local users on my laptop.
  • If you are happy with the output then remove the appropriate echo commands and run the script again.

DeleteUsers.cmd:

@echo off
setlocal 
rem skip first line
rem use findstr to strip blank lines from wmic output
for /f "usebackq skip=1" %%i in (`wmic useraccount get name ^| findstr /r /v "^$"`) do (
  echo net user %%i /del
  echo rd /s /q "C:\Users\%%i"
  )
endlocal

Example Output:

F:\test>wmic useraccount get name
Name
Administrator
DavidPostill
Guest
ntp


F:\test>deleteusers
net user Administrator /del
rd /s /q "C:\Users\Administrator"
net user DavidPostill /del
rd /s /q "C:\Users\DavidPostill"
net user Guest /del
rd /s /q "C:\Users\Guest"
net user ntp /del
rd /s /q "C:\Users\ntp"

F:\test>

Further Reading

DavidPostill

Posted 2016-03-03T17:01:21.870

Reputation: 118 938