vbscript to delete multiple specific local user accounts from servers

i am trying to write a vbscript to delete specific user account from server. 
If in server found the users adm,ame the script should delete and also it should print the result whether the deletion is successful or not. Below is the script which I tried writing and I am getting an error . Can anyone help me to correct this ?

Dim disuser, objNetwork, strComputer, objComputer

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("WinNT://" & strComputer)
On Error Resume Next

For each disuser In "adm  ame"
Call objComputer.Delete("user", disuser)
On Error GoTo 0
'On Error res="fail" 

1 Comment   [ + ] Show comment
  • I use a free program called delprof2 for this task. - flip1001 5 years ago

Answers (1)

Posted by: anonymous_9363 5 years ago
Red Belt

psexec [remote_computer's NetBIOS_name] /s net user [local_account_to_be_removed]  /delete

If you need a VBS, there are a quadzillion example scripts out there!! Before that though, go to the VB Script section of DevGuru.com and look up the syntax for 'For Each...' constructs.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ