Jump to content
Sign in to follow this  

Delete User Profile

Recommended Posts

Hey all,

I have been modifying VB code that some of you may have seen that is supposed to delete user profiles. I have made it through Object creation, pinging, and connecting to a remote PC. I have learned a few things. However, I am struggling with what is in red:

if not objItem.SID = "" then

if objItem.SID = "S-1-5-20" then

deleteResponse = 7

elseif objItem.SID = "S-1-5-19" then

deleteResponse = 7

elseif objItem.SID = "S-1-5-18" then

deleteResponse = 7


deleteResponse = MsgBox (strMessage,35,"Profile Found")

end if

end if

Select Case deleteResponse

Case 6



If Err.Number = 0 Then

MsgBox("Profile " & objitem.localpath & " on " & strComputer & " deleted")


MsgBox("Profile " & objitem.localpath & " on " & strComputer & " NOT deleted - Is user logged in?")

End If

End Select

What is the Err.Clear equivalent in AutoIt along with ObjItem.Delete_ ??

Share this post

Link to post
Share on other sites

Err.clear should probably be SetError(0)

I have a feeling that ObjItem.Delete_ is calling another function but I can't be sure without seeing all the code involved and even then it might be tough.


Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver: - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post

Link to post
Share on other sites

Lol, I have some code already built in autoit that does exactly what you want. Deleting profiles. However I'm away from my work computer for another 3 or 4 days since I'm out of the country. If you don't have anything by then I'll post it when I get back.

Edited by kor

Share this post

Link to post
Share on other sites

Thanks, Spammer. I may need that assistance. Until then I will add now that Objitem.delete_ is deleting the found object in VB. I can't figure out how that works in AutoIt. If I do figure this out, I will update.

Edited by Discovery164

Share this post

Link to post
Share on other sites

Thanks, Spammer.

It's kor! :unsure:

UDF List:

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post

Link to post
Share on other sites

After looking at my script it doesn't do exactly what you're doing, but it's close.

I use this function.

#include <Date.au3>

_DeleteOlderThan("C:\test", 5)

Func _DeleteOlderThan($sDirectory, $iDays)
    ; must include <Date.au3>
    Local $sWorking = FileChangeDir($sDirectory) ; change working directory
    Local $sDate = (@YEAR & "/" & @MON & "/" & @MDAY) ; set date, must use year month day format
    Local $hSearch = FileFindFirstFile("*") ; show all files in current directory
    If $hSearch = -1 Then Exit ; no files/directories matched the search pattern
    While 1
        Local $hFiles = FileFindFirstFile($hSearch)
        If @error Then ExitLoop
        If $hFiles = "." Or $hFiles = ".." Then ContinueLoop ; block output of root and current directories
        Local $aFileDate = FileGetTime($hFiles, 0, 0)
        If Not @error Then $sFormatDate = $aFileDate[0] & "/" & $aFileDate[1] & "/" & $aFileDate[2]
        Local $sDateDiff = _DateDiff("D", $sFormatDate, $sDate)
        If $sDateDiff > $iDays Then DirRemove($hFiles, 1)
EndFunc   ;==>_DeleteOlderThan

Share this post

Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...