Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Disabling local users

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,54852
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Disabling local users
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Disabling local users - 1/3/2008 5:56:04 AM   
  cshiers

 

Posts: 24
Score: 0
Joined: 4/28/2005
From:
Status: offline
Need help disabling local users starting with a certain string.

This is what I have so far. I just don't know how to isolate only the user accounts that start with USR_


      
 
 
Post #: 1
 
 RE: Disabling local users - 1/3/2008 6:01:01 AM   
  dm_4ever


Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline

      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to cshiers)
 
 
Post #: 2
 
 RE: Disabling local users - 1/3/2008 6:01:02 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
 

Set objNetwork = CreateObject("Wscript.Network")
strComputer = "."
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
  
'disable only users starting with USR
if UCase(Left(objUser.Name, 3)) = "USR" Then
objUser.AccountDisabled = true
  objUser.SetInfo
End If
Next

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to cshiers)
 
 
Post #: 3
 
 RE: Disabling local users - 1/3/2008 6:01:57 AM   
  dm_4ever


Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
hahaha...look at those time stamps

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ebgreen)
 
 
Post #: 4
 
 RE: Disabling local users - 1/3/2008 6:06:28 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Nice. If only I hadn't bothered with the coloring.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: Disabling local users - 1/3/2008 6:07:25 AM   
  cshiers

 

Posts: 24
Score: 0
Joined: 4/28/2005
From:
Status: offline
Thanks ebgreen. Just saved me a ton of time.

(in reply to cshiers)
 
 
Post #: 6
 
 RE: Disabling local users - 1/3/2008 6:10:10 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Actually if you are really looking for USR_ then the if statement that DM did is more correct.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to cshiers)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Disabling local users Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts