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.
Please log in to comment



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.

Answered 04/15/2016 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity