Jump to content

Need to delete profiles from XP Pro!


Bradman
 Share

Recommended Posts

I have some systems we use in a classroom at work and we need to every so often delete the student profiles. I understand how to delete a single directory but how would you do it without deleting the All User, Administrator or any other account you wanted to keep? ( I am fairly new to this so I don't have alot of knowlege).

TY

Link to comment
Share on other sites

I have some systems we use in a classroom at work and we need to every so often delete the student profiles. I understand how to delete a single directory but how would you do it without deleting the All User, Administrator or any other account you wanted to keep? ( I am fairly new to this so I don't have alot of knowlege).

TY

I have gotten this far, but not sure what to do from here?

Run('explorer /select, C:\Documents and Settings\All Users'); This would show the folders!

DirRemove("C:\Documents and Settings", 1) ; This would delete all the sub-folders and files ! How would you search and keep only the directories you want?

Link to comment
Share on other sites

for deleting profiles you want to use Delprof.exe from microsoft. it basically will renmove all profiles bar the lofgged in account & alluser & default user profiles. you can also set it to only delete profiles older than a specified no. of days. if there is profiles you need to keep that i have not mentioned then you have to hide them before running Delprof.exe.

i have written a little cleanup script for PC's & removing the profiles is part of that.

;*******************************************************************************

;Remove User Profiles

;*******************************************************************************

Run("\\server\Software\OS\Windows XP\DelProf\Delprof.exe")

winwait("\\server\Software\OS\Windows XP\DelProf\Delprof.exe")

Send("y")

Send("{ENTER}")

winwaitclose("\\server\Software\OS\Windows XP\DelProf\Delprof.exe")

Link to comment
Share on other sites

@Psibernetic

Maybe this can get you going. Use it on you own risk !!

#include <date.au3>


$strComputer = "." 
$today = _NowDate () 

Const $ForAppending = 8 

 $objWMIService = ObjGet("winmgmts:" _ 
    & "{impersonationLevel=impersonate}!\\" & $strComputer 
& "\root\cimv2") 
 $colSubfolders = $objWMIService.ExecQuery _ 
    ("ASSOCIATORS $OF {Win32_Directory.Name=;C:\Documents and Settings;} " _ 
        & "WHERE AssocClass = Win32_Subdirectory " _ 
            & "ResultRole = PartComponent") 
;                               & 
 $objfso = ObjCreate("Scripting.Filesystemobject") 
 $objFile = $objfso.OpenTextFile("C:\profilelog.txt", 
$ForAppending) 

    $objFile.writeline ("Computer Name: " & $strComputer )
    $objFile.writeline ("   " )
For $objFolder in $colSubfolders 
$lastm=_DateDiff("d",WMIDateStringTODate 
($objFolder.LastModified),$today) 
  $objFile.WriteLine ("The Profile: " & $objFolder.name & " )
$was $last $accessed: " & $lastm &" $days ago" 

    $proname=$objFolder.name 
    $res=IsNumber(StringRight($proname,5)) 

    If $res = 1  Then 
                $objFile.WriteLine ( "Profile is a studentes" )
         If $lastm > 365 Then 

                $objFile.WriteLine ( $objFolder.name & " is )
$older $the 1 year $it $will $be $deleted " 
;               $objFolder.Delete 
        EndIf 
    EndIf 

 $objFile.writeline ("   " )
Next 

Consolewrite("All Profiles Checked" )
$objFile.Close ()


Func WMIDateStringToDate($dtmDate) 
    Local $Return
    $Return = CDate(StringMid($dtmDate, 5, 2) & "/" & _ 
         StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) & " ") 
    Return $Return
EndFunc

regards,

ptrex

Edited by ptrex
Link to comment
Share on other sites

  • 2 weeks later...

Hey, I have tried to get the DELPROF from Microsoft to run remotely, and I am not sure what I have been doing wrong!

Here is what I have so far.

My goal is to read from a text file that has the computer names on it.

I need the script to read from the first line and turn that comp name into a variable to be put in the remote path soforth with each additional line.

I need the script to try and run each computer name and have some kind of error control.

Here is what I have so far. All I get is the message box that pops and says the script did not run. I think my syntax is messed up and i am not quite sure how to read from a file AND convert to a variable. Any help or sugestions would be nice.

$g_szVersion = "My Script 1.1"

If WinExists($g_szVersion) Then Exit

AutoItWinSetTitle($g_szVersion)

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

Opt("RunErrorsFatal", 0)

HotKeySet("^!x", "MyExit")

RunAsSet("administrator", @ComputerName, "password")

Run(@COMSPEC & " /c Start c:\delprof /p /c:\\computername")

Run("delprof.exe /p /c:\\computername", "",@SW_MAXIMIZE)

If @error Then MsgBox(16, 'WARNING', 'DELPROF.EXE DID NOT RUN!',5)

RunAsSet()

Func MyExit()

Exit

EndFunc

I am not sure of the syntax for the run! I plan on recording the windows so I can set delays and create a log function. I figured out how to make a log file by using IF WinExists Then.....

Thanks to everyone for the help!

From

Bradman the NOOB!

Link to comment
Share on other sites

Maybe I am not clear on what I need. I have 21 systems in a classroom environment. I need to periodically delete all the user profiles. I want to do this remotely from one machine. I want to have the script do the following:

1. Log onto each machine to run the Delete Profile from Microsoft. I am having problems with the proper syntax for the network path thats why you see 3 different Run statements in the pervious post.

2. The script needs to read the PC name from a TXT file and write the name in the network path. I know how to open a file and write but not how to read and pass the info off to the network path.

3. I can figure out the basic logging function. I will use the (If WinExists Then Open File Write ) functions to write to a txt file.

4. I am also not familiar with the Loop Until function. This would be nice if the machine is slow to respond.

I do not need some one to write the script for me I just need good examples on how to do certain things. I just want to say I see allot of very talented people here that really know how to script and I know that one day I will have the skills to help others here on the Forums. I just started a little over a month ago and I have learned so much. I want to thank those that take their time here on the Forums to help others.

Link to comment
Share on other sites

Here is the Command options for DELPROF. I am still having problems with the syntax. I am not sure if it is from the network/security side or if I just messed up the script.

DELPROF

Delete NT user profiles.

Syntax

DELPROF [options]

Key

/Q Quiet, no confirmation.

/I Ignore errors and continue deleting.

/P Prompts for confirmation before deleting each profile.

/C:\\computer_name

Delete profiles on a remote computer.

/D:Number_of_days

Only delete profiles that have been inactive for

'X' Number of days (or greater)

/R Delete roaming profile cache only ##

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...