WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: morenos1 on November 20, 2014, 09:02:45 AM

Title: Removing windows 7 profile.
Post by: morenos1 on November 20, 2014, 09:02:45 AM
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
Title: Re: Removing windows 7 profile.
Post by: morenos1 on November 20, 2014, 10:29:34 AM
"Folder is in use" when trying to delete user folder manually from administrator account ...
Title: Re: Removing windows 7 profile.
Post by: td on November 20, 2014, 10:38:20 AM
Out of curiosity, is the user logged on?
Title: Re: Removing windows 7 profile.
Post by: morenos1 on November 20, 2014, 10:46:29 AM
Not @ all .....
Title: Re: Removing windows 7 profile.
Post by: morenos1 on November 20, 2014, 11:11:56 AM
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 .....
Title: Re: Removing windows 7 profile.
Post by: td on November 20, 2014, 11:23:59 AM
That was the other option; a service, system or otherwise, with an open file handle. 

Thanks for reporting your findings.
Title: Re: Removing windows 7 profile.
Post by: morenos1 on November 20, 2014, 12:44:29 PM
Anybody knows why the "delete" button is greyed on some of the profiles? ....
Title: Re: Removing windows 7 profile.
Post by: td on November 21, 2014, 06:51:05 AM
Are you referring to the 'Remove' button in the Users tab of the User Accounts dialog?
Title: Re: Removing windows 7 profile.
Post by: morenos1 on November 21, 2014, 12:02:48 PM
No. I am referring to the "delete" button on the "User Profiles" ....
Title: Re: Removing windows 7 profile.
Post by: td on November 21, 2014, 01:14:22 PM
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.
Title: Re: Removing windows 7 profile.
Post by: td on November 21, 2014, 01:30:57 PM
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.