Jump to content

Recommended Posts

Posted

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

Posted

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 ?

Posted

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

Posted

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?

Posted

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 :-)

Posted

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.

Posted

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.

Posted
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

  • 1 year later...
Posted
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
Posted
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.

Posted
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?
  • 7 months later...
Posted
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.

Posted

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.

Posted

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.

Posted
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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...