+ Post New Thread
Results 1 to 5 of 5
Windows Thread, Script to delete all local user accounts in Technical; hi, Has anyone got a script that deletes all local user accounts, except ones I specify such as the administrator ...
  1. #1

    Join Date
    Jun 2010
    Location
    England
    Posts
    735
    Thank Post
    89
    Thanked 52 Times in 46 Posts
    Rep Power
    35

    Script to delete all local user accounts

    hi,
    Has anyone got a script that deletes all local user accounts, except ones I specify such as the administrator account and service accounts and also enables and sets a password for the local admin account.
    Its for windows7.

    Thanks

  2. #2
    ricki's Avatar
    Join Date
    Jul 2005
    Location
    uk
    Posts
    1,475
    Thank Post
    20
    Thanked 164 Times in 157 Posts
    Rep Power
    52
    Have a see if this will do what you want How to Add domain accounts to Local Administrators Group using GPO - Richard&#39s myITforum Blog

    Richard

  3. #3

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,942
    Thank Post
    886
    Thanked 1,694 Times in 1,472 Posts
    Blog Entries
    12
    Rep Power
    447
    Are you using Server 2008 R2? You can do this in group policy preferences

  4. #4
    Gibbo's Avatar
    Join Date
    Feb 2008
    Location
    Cheshire
    Posts
    902
    Thank Post
    207
    Thanked 344 Times in 238 Posts
    Rep Power
    93
    I have this batch file:

    Code:
    @echo off
    c:
    cd\
    cd "c:\Documents and Settings\"
    dir *.* /b /o:d > \dirs.txt
    for /f "tokens=*" %%a in (\dirs.txt) do call :DelFiles "%%a"
    del \dirs.txt
    exit /b
    
    :DelFiles %1
    set Flag=0
    if %1=="All Users" set Flag=1
    if %1=="Administrator" set Flag=1
    if "%Flag%"=="0" (
    cd %1
    attrib *.* -r /s
    cd..
    rem change rd %1 /s /q
    rem for no confirmation
    rd %1 /s /q
    )
    or a nice VB script:

    Code:
    On Error Resume Next
    	 Dim obtainfolder
    	 Dim Pathfinder
    	 Dim strPath
    
    	 Set fso = CreateObject("Scripting.FileSystemObject")
    
    	 strPath = "C:\Documents and Settings\"
    	 
    	 userexcludelist = "Administrator,All Users,Default User,localservice,networkservice,"
    	
    	 Set f = fso.GetFolder(strPath)
    
    	 ' Loop through all subfolders
    	 For Each fldrItem in f.SubFolders
    	   fldrName = fldrItem.name
    	   If Right(strPath,1) <> "\" Then
    	     Pathfinder = strPath & "\" & fldrName
    	   Else
    	     Pathfinder = strPath & fldrName
    	   End If
    
    	   If InStr(1, ".00", fldrName, 1) Then
    	     set obtainfolder = fso.GetFolder(Pathfinder)
    	     obtainfolder.Delete true
    	   Else
                    
                    End If
    	 Next
    
    	 ' Clean up objects
    	 Set fso = Nothing
    	 Set fc = Nothing

  5. #5
    bio
    bio is offline
    bio's Avatar
    Join Date
    Apr 2008
    Location
    netherlands
    Posts
    520
    Thank Post
    16
    Thanked 130 Times in 102 Posts
    Rep Power
    37
    check my blog here and look for Shonks script.

    bio..

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 5
    Last Post: 1st July 2014, 08:34 AM
  2. Replies: 6
    Last Post: 26th September 2008, 03:57 PM
  3. Replies: 3
    Last Post: 25th September 2006, 12:27 PM
  4. Replies: 7
    Last Post: 27th November 2005, 10:41 PM
  5. Script to create a local user on a XP box.
    By tosca925 in forum Scripts
    Replies: 3
    Last Post: 12th October 2005, 12:04 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •