Removing windows 7 profile.

Started by morenos1, November 20, 2014, 09:02:45 AM

Previous topic - Next topic

morenos1

This code will remove the Windows 7 profile but, not the file folder structure for the profile.

It returns a: WIL Extender Error 575.

; Load Appropriate Extender
AddExtender('wwwnt34i.dll',0,'wwwnt64i.dll')

key = RegOpenKey(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList")
profilelist = RegQueryKeys(key)
count = ItemCount(profilelist,@TAB)
list = ""
For x = 0 To count-1
   accountSID = ItemExtract(x+1,profilelist,@TAB)
   profilepath= RegQueryExpSz(key,StrCat(accountSID,"\[ProfileImagePath]"))
   accountname = wntAcctInfo("", accountSID, 2, 1)
   
   If accountname == "OAK\adm_omoreno"
   
      ProfilePath = StrReplace(ProfilePath, "%%SystemDrive%%", Environment("SystemDrive"))
   ProfilePath = StrReplace(ProfilePath, "%%SystemRoot%%", Environment("SystemRoot"))
      wntProfileDel( "" , accountSID , profilepath )
      
   Endif
Next

RegCloseKey(key)

Exit

morenos1

"Folder is in use" when trying to delete user folder manually from administrator account ...

td

Out of curiosity, is the user logged on?
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

morenos1


morenos1

It turns out to be something called "Real Player Cloud Service" holding files open.

I disabled the service and, I can remove the folder structure .....

td

That was the other option; a service, system or otherwise, with an open file handle. 

Thanks for reporting your findings.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

morenos1

Anybody knows why the "delete" button is greyed on some of the profiles? ....

td

Are you referring to the 'Remove' button in the Users tab of the User Accounts dialog?
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

morenos1

No. I am referring to the "delete" button on the "User Profiles" ....

td

You are referring to a dialog which is one of several dialogs displayed by the sysdm.cpl control panel tool.  The usual explanation for the 'Delete' button being grayed on the dialog you are referring to is that the system has not released the profile's registry hive for some reason.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

If you are curious, you could always use system internal's Process Explorer to see which processes have a handle to a particular user's ntuser.dat and ntuser.dat.whatever files.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade