mac_shinobi Posted August 25, 2005 Posted August 25, 2005 ok I have this vbscript below which is to delete all local profiles except for the specific ones which are in the select case statement : Function Main() On Error Resume Next Dim obtainfolder Dim PathFolder Dim strPath Set fso = CreateObject("Scripting.FileSystemObject") strPath = "C:\Documents and Settings\" Set f = fso.GetFolder(strPath) ' Loop through all subfolders For Each fldrItem in f.SubFolders fldrName = fldrItem.name If Right(strPath,1) <> "\" Then PathFolder = strPath & "\" & fldrName Else PathFolder = strPath & fldrName End If Select Case fldrName Case "Administrator": Case "All Users": Case "Default User": Case "supervisor.CSE2K" Case "supervisor": Case "sweepupd" Case "sweepupd.CSE2K" Case "LocalService": Case "NetworkService": Case Else: set obtainfolder = fso.GetFolder(PathFolder) obtainfolder.Delete true End Select Next ' Clean up objects Set fso = Nothing Set fc = Nothing End Function call Main() now I would like help with it so that It can have an array which is re dimmed each time it gets to a folder which can not be deleted and take that folders name and stores that folders name into the array so that near the end of this vbscript it has some way of detecting once the script has finished doing what it can and then prompts you with all the folders ( local profiles ) that it could not delete and also get the size of the documents and settings folder before and after and in the messagebox show the amount in mb of how much it has cleared out or freed. I hope that makes sense If anyone can make any suggestions to improve this script aside from that, then feel free to make them. Thanks Shane
tosca925 Posted August 25, 2005 Posted August 25, 2005 Can this be run through a GPO or does it have to be run locally?
mac_shinobi Posted August 25, 2005 Author Posted August 25, 2005 Just so you know I am working under the network manager and am learning about server 2003. ok GPO as in group policies correct ? If so then it depends on how GPO would make this work, so far we have just run it locally. If I figured out how to use UNC paths and such like in vbs then I am sure you could run it from the server , but if you were going to do something like that then it would be worth while just making an application in visual basic or another language that would do it then. I think a better way would be a login script possibly or even a log out script maybe ? Maybe you can ellaborate on how GPO would run the script or how it would work with GPO etc ?
mac_shinobi Posted August 28, 2005 Author Posted August 28, 2005 I have an updated one if anyone is interested in any updated versions of this script then please post back here I will be working on the UNC version later on If you would like a script like this that would work with GPO then please let me know here Thanks
Ric_ Posted August 28, 2005 Posted August 28, 2005 You could add this to the startup script in the GPO (Group Policy Object) for your machines. Would the Microsoft tool (Delprof) not suffice for what you want?
kingswood Posted August 28, 2005 Posted August 28, 2005 Good point actually. I think we started using the script that Gecko wrote so that we didn't delete profiles that we aren't (because of our managed solution on those machines) supposed to delete (or can't). But thinking about it, isn't there a command-line switch you can use with DelProf that let's you decide whether a profile is deleted or not---is it DELPROF /P? ...got me thinking though, and that's very dangerous at the weekend! Paul :-)
tosca925 Posted August 29, 2005 Posted August 29, 2005 I thought there was a setting in server 2003 GPO that you can set that deletes or does not store profiles? Can't remember the official wording, will lookwhe i am back in on Wednesday.
ICTNUT Posted August 29, 2005 Posted August 29, 2005 Tosca925 is correct there is a GPO setting that allows for either profiles to be deleted at logoff or not to be stored at all. For the life of me I can not remember where it is but i'll also take a look on Wednesday.
Ric_ Posted August 29, 2005 Posted August 29, 2005 It's something like delete cached profiles on logoff but it doesn't always work - hence why MS developed the Delprof utility. Check out the document at http://www.microsoft.com/downloads/details.aspx?FamilyID=7821c32f-da15-438d-8e48-45915cd2bc14&DisplayLang=en which tells you all the GPO settings that are available and where they live.
tosca925 Posted August 29, 2005 Posted August 29, 2005 It's something like delete cached profiles on logoff but it doesn't always work Yeah i've noticed that it does not always work, thought i was going mad to start with. Thanks for the GPO link, will have a look at that when i have got 5
Geoff Posted August 29, 2005 Posted August 29, 2005 You might want to check out Remote User Profile Cleaner. http://www.msimons.nl
mac_shinobi Posted August 30, 2005 Author Posted August 30, 2005 thats a cool website will have to make a note of that so I dont lose that url, thanks Geoff !
marx Posted October 20, 2006 Posted October 20, 2006 Hi. Does anyone know how to creat a batch file to remotly delete profiles using delprof except Administrator,defual and some specific profile. I can see someone done a VB but I require a batch file realy. any help apreciated..please dont reply and say use "Remot profile cleaner". thanks
webman Posted October 20, 2006 Posted October 20, 2006 will have to make a note of that so I dont lose that url del.icio.us - online social bookmarks.
djm968 Posted October 20, 2006 Posted October 20, 2006 Hi. Does anyone know how to creat a batch file to remotly delete profiles using delprof except Administrator,defual and some specific profile. I can see someone done a VB but I require a batch file realy. any help apreciated..please dont reply and say use "Remot profile cleaner". thanks Delprof will delete all user profiles but you could copy the profiles you want keep somewhere and bring them back in after you run delprof Something like this: XCOPY /S "C:\Documents and Settings\%userprofile%" "C:\ProfileBackupFolder\%userprofile%" DELPROF /Q /I XCOPY /S "C:\ProfileBackupFolder\%userprofile%" "C:\Documents and Settings\%userprofile%" Delprof will not touch any other folders in the "C:\Documents and Settings" folders, such as "All Users", "Default User, "LocalService" and "NetworkService", it will only delete "real" user profiles. I would run the batch file in a computer shutdown script (with a GPO) that runs as part of the or shutdown process becuase it could take a long time to delete the profiles.
plexer Posted October 20, 2006 Posted October 20, 2006 If I figured out how to use UNC paths and such like in vbs Erm you just use them I have lots of vbs with unc paths in. Ben
chrbb Posted October 20, 2006 Posted October 20, 2006 sorry really silly question here but would deleting the local profiles delete all in that profile's 'my documents'?
djm968 Posted October 20, 2006 Posted October 20, 2006 Not a silly question but the answer is yes, that is one of the reasons why we redirect users My Documents folders to a file server.
chrbb Posted October 20, 2006 Posted October 20, 2006 None of our users save to 'my docs' but to their drive on network, but ... teachers save onto their laptops at home then save anything they can't afford to lose to their network share (in theory), so if this was applied to all users via gpo would their docs be deleted as well?
NetworkGeezer Posted June 13, 2007 Posted June 13, 2007 None of our users save to 'my docs' but to their drive on network, but ... teachers save onto their laptops at home then save anything they can't afford to lose to their network share (in theory), so if this was applied to all users via gpo would their docs be deleted as well? This should be a problem if the GPO is a loop back on an OU for student PCs or if the script is run as a scheduled job on each of the machines. Either way you can determine which macines to ignore.
NetworkGeezer Posted June 13, 2007 Posted June 13, 2007 Delprof will delete all user profiles but you could copy the profiles you want keep somewhere and bring them back in after you run delprof Something like this: XCOPY /S "C:\Documents and Settings\%userprofile%" "C:\ProfileBackupFolder\%userprofile%" DELPROF /Q /I XCOPY /S "C:\ProfileBackupFolder\%userprofile%" "C:\Documents and Settings\%userprofile%" How about just using the MOVE command. This works folders so longs as you don't try to jump across drive/partition boundary. It will be quicker than XCOPY as it just involves changes to the file table rather than copying whole files. Besides I think you would need the /H switch or else it wouldn't copy the user hive which is normally hidden. Delprof will not touch any other folders in the "C:\Documents and Settings" folders, such as "All Users", "Default User, "LocalService" and "NetworkService", it will only delete "real" user profiles. If you wanted to be really fancy you could get the SID prefix of the group users you want to delete then search for the corresponging paths in the profilepath key in HKLM.
alonebfg Posted June 13, 2007 Posted June 13, 2007 I have never used delprof befor i have just downloaded it (its a msi) so what do i do deploy it via gpo then run a bat file with DELPROF /Q /I and run this at shutdown but what i would like to do is a sync befor this happens any idears.
NetworkGeezer Posted June 13, 2007 Posted June 13, 2007 If they're removing profiles then they should have been synced at logoff. Could you explain what you mean by syncing?
alonebfg Posted June 13, 2007 Posted June 13, 2007 ie i want sync offline files befor deleting profiles as part of a switch off routine. The ideal thing woluld be if it was unable to sync the dont run delprof but if it does then run delprof but dont know how to do it.
alonebfg Posted June 13, 2007 Posted June 13, 2007 ok something like this mobsync if mobsync = fail goto end elseif delprof or something like that
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now