Jump to content

DeleteProfile


Recommended Posts

How can I write a AutoIT Script that use the WinApi DeleteProfile?

How can I define a NULL Parameter?

More Documentation about the function can be found here:

http://msdn.microsoft.com/en-us/library/bb762273(VS.85).aspx

....

Deletes the user profile and all user-related settings from the specified computer.

The caller must have administrative privileges to delete a user's profile.

BOOL WINAPI DeleteProfile(

LPCTSTR lpSidString,

LPCTSTR lpProfilePath,

LPCTSTR lpComputerName

);Parameters

lpSidString

[in] Pointer to a string that specifies the user SID.

lpProfilePath

[in] Pointer to a string that specifies the profile path. If this parameter is NULL, the function obtains the path from the registry.

lpComputerName

[in] Pointer to a string that specifies the name of the computer from which the profile is to be deleted. If this parameter is NULL, the local computer name is used.

Return Value

....

Link to comment
Share on other sites

Thank you

Now I write a little sample.

;http://msdn.microsoft.com/en-us/library/bb762273(VS.85).aspx
#RequireAdmin

#include <Security.au3>
Dim $ACCOUNT = "Test1"; Replace this Account but be carefully
ConsoleWrite("get the SID from UserID " & $ACCOUNT & @CRLF)
$ArrSid = _Security__LookupAccountName($ACCOUNT)
If @error Then
    ConsoleWrite("Errorcode:" & @error & " Extendedcode: " & @extended & @CRLF)
    Exit 1
EndIf
ConsoleWrite("UserID " & $ACCOUNT & " have the SID " & $ArrSid[0] & @CRLF)

ConsoleWrite("try to delete Profile " & $ACCOUNT & @CRLF)
$Return = DllCall("Userenv.dll", "int", "DeleteProfile", "str", $ArrSid[0], "ptr", 0, "ptr", 0)
If @error Then
    ConsoleWrite("Returncode:" & $Return & " Errorcode:" & @error & " Extendedcode: " & @extended & @CRLF)
    Exit 2
EndIf
if $Return[0]= 1 then 
ConsoleWrite("Successfull" & @CRLF)
Else
    ConsoleWrite("Profile couldn't delete, mabye not exist" & @CRLF)
EndIf
Link to comment
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
 Share

  • Recently Browsing   0 members

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