?
Solved

Selective delete of profile using VBscript

Posted on 2005-03-18
2
Medium Priority
?
300 Views
Last Modified: 2008-02-01
Hi, I have a domain comprising of a mixture of W2k professional SP4 machines and WXP Professional SP2 machines.  All of these have a lot of unwanted local profiles on which it takes my colleagues and I a few days to delete.

Can anyone give me a hand writing a vbscript that will delete all of the local profiles from these workstations except for a select few.  E.g:

>Administartor
>All Users
>Default User
>Sweepupd

Is it possible to do a wild card for the administrator profile because there a lot of them e.g. administrator.001, administrator.bramcote etc.  Can i just put administrator* that would protect all of these accounts?

Many thanks in advance.

Ryan Powell
0
Comment
Question by:anubis_bc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13576233
you would first of all have to detect all the profiles on the computer and then from there do a select case or if statement to see which user profiles are not the ones you mentioned and that way you can determine which ones need deleted :

http://www.robvanderwoude.com/index.html

Here is a site that has 1 or 2 scripts with regards to deleting corrupted profiles, so that might give you an idea of how to delete them. I also have a script which I will post here that enumerates all users and groups on the computer, so that should help you to some extent :

' Get the name of the computer
str_Computer = WScript.CreateObject("WScript.Network").ComputerName

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set oOutFile = oFSO.CreateTextFile("c:\usersandgroups.txt")

' Connect to the computer object
set oMachine = getObject("WinNT://" & str_Computer & ",computer")

' Set the filter to list users
oMachine.Filter = Array("group")

' For each group on the machine
For Each oGroup in oMachine
  oOutFile.writeline oGroup.Name

  ' For each user in the group
  For Each oUser in oGroup.Members
    ' display the user name
    oOutFile.writeline  vbTab & oUser.Name
  Next
Next

oOutFile.Close

Set oOutFile = Nothing
Set oFSO = Nothing



0
 
LVL 23

Accepted Solution

by:
gecko_au2003 earned 375 total points
ID: 13576248
I would also suggest that you run a test with your newly created script ie do NOT delete the accounts, just get a message box to display to you which accounts are not the ones you mentioned, this way you can see which ones it would normally delete if you use the delete command, hence you are on the safe side and not deleting accounts left right and center:)
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Introduction to Processes

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question