Jump to content

Get logged user information with script in Required Admin


Go to solution Solved by Gianni,

Recommended Posts

#include <GuiConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <File.au3>
    #include <String.au3>
    #include <GuiButton.au3>
    #include <ComboConstants.au3>
    #include <Constants.au3>
    #include <ScreenCapture.au3>
    #include <MsgBoxConstants.au3>
    #include <Array.au3>
    #include <ButtonConstants.au3>
    #include <StaticConstants.au3>
    #include <EditConstants.au3>
    #include <GuiStatusBar.au3>
    #include <AutoItConstants.au3>
    #include <GuiTab.au3>
    
#RequireAdmin


    $oMyError = ObjEvent("AutoIt.Error", "ComError")
    $UserObj = ObjGet("WinNT://" & @LogonDomain & "/" & @UserName)

If @error Then

    MsgBox(0,0,"Not found!",0)


Else

    MsgBox(0,0,$UserObj.FullName, 0)
    MsgBox(0,0,$UserObj.description, 0)

EndIf





$UserObj = ""

$oMyError = ObjEvent("AutoIt.Error", "")

;COM Error function

Func ComError()

    If IsObj($oMyError) Then

        $HexNumber = Hex($oMyError.number, 8)

        SetError($HexNumber)

        Else

            SetError(1)

        EndIf

    Return 0

EndFunc  ;==>ComError

Good morning everyone,

How can I correct the script below?

I am required by definition that the script works with admin powers.

When running it brings me the admin user and not the user who is currently logged into Windows.

How to fix if possible?

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...