/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


vbscript to delete multiple specific local user accounts from servers

04/14/2016 1395 views
Hi,
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
Next
'On Error res="fail" 

1 Comment   [ + ] Show comment

Comments

  • I use a free program called delprof2 for this task.

All Answers

0

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