Jump to content
Sign in to follow this  
Paulchen

DeleteProfile

Recommended Posts

Paulchen

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

....

Share this post


Link to post
Share on other sites
SmOke_N

"ptr", 0


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Paulchen

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

Share this post


Link to post
Share on other sites
Paulchen

Paulchen

Maybe this be easy?

How to Use the Net User Command

That's not the same.

The net user delete the account an not the Profile, deleteprofile function delete only the profile.

Share this post


Link to post
Share on other sites
rasim

Paulchen

That's not the same.

The net user delete the account an not the Profile, deleteprofile function delete only the profile.

Understand. ;)

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  

×