╃苍狼山庄╃╃苍狼山庄╃

Clang出品,
必属精品!

AutoIt修改系统帐户

Func _NetUserChangeName($sUserName, $sNewName, $sSystem = "")
        Local $iResult, $tName, $pName, $tUserName, $pUserName

        $tName = DllStructCreate("wchar[256]")
        $pName = DllStructGetPtr($tName)
        DllStructSetData($tName, 1, $sNewName)

        $tUserName = DllStructCreate("ptr")
        $pUserName = DllStructGetPtr($tUserName)
        DllStructSetData($tUserName, 1, $pName)

        $iResult = DllCall("netapi32.dll", "dword", "NetUserSetInfo", _
                        "wstr", $sSystem, "wstr", $sUserName, _
                        "dword", 0, "ptr", $pUserName, "int*", 0)
        $tName = 0
        $tUserName = 0
        Return SetError($iResult[0], 0, $iResult[0] = 0)
EndFunc        ;==>_NetUserChangeName()


使用方法:

_NetUserChangeName("要修改的用户名", "修改后的用户名")

例:

$iResult = _NetUserChangeName("test", "NewName")
If $iResult Then
        Msgbox(0, "", "Done!")
Else
        Msgbox(0, @error, "Failed")
EndIf

本原创文章未经允许不得转载 | 当前页面:╃苍狼山庄╃ » AutoIt修改系统帐户

评论

文章评论已关闭!