Adele Posted June 12, 2014 Share Posted June 12, 2014 (edited) Hi all. How can I get current user type? I want to get is user administrator or is standard user. I can't use the IsAdmin() function because if uac is active, this returns negative value. I've searched but I haven't found. Thank you in advance. Edited June 12, 2014 by sanaldosya Link to comment Share on other sites More sharing options...
Danyfirex Posted June 12, 2014 Share Posted June 12, 2014 Maybe using http://msdn.microsoft.com/en-us/library/bb776463(v=vs.85).aspx but I'm no sure if isAdmin is a wrapped of this. Saludos Adele 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
guinness Posted June 12, 2014 Share Posted June 12, 2014 That's deprecated. Adele 1 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Danyfirex Posted June 12, 2014 Share Posted June 12, 2014 Use CheckTokenMembership instead... Adele 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Adele Posted June 12, 2014 Author Share Posted June 12, 2014 Use CheckTokenMembership instead... Thank you but how can I use this? Can you give example with AutoIt? Link to comment Share on other sites More sharing options...
Developers Jos Posted June 12, 2014 Developers Share Posted June 12, 2014 What exactly is it you want to do that doesnt work with isadmin()? Adele 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Adele Posted June 12, 2014 Author Share Posted June 12, 2014 (edited) I will add restricted version to my program. If user is standard user, will run restricted version. If user is administrator, will run completely version. Even if user is administrator, if uac is active IsAdmin() function returns negative value. Edited June 12, 2014 by sanaldosya Link to comment Share on other sites More sharing options...
Developers Jos Posted June 12, 2014 Developers Share Posted June 12, 2014 So you want to know whether the current userid is part of the administrators group of the computer? It is clear that the isadmin() will only return a 1 when actually running at that level. Jos Adele 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Adele Posted June 12, 2014 Author Share Posted June 12, 2014 (edited) Yes, I want this. If add #RequireAdmin, my program won't run in standard users. If administrator user has password, will want password. Instead I want to run restricted version. If user is administrator, with this code will want uac permission. ShellExecute(@ScriptFullPath, "", "", "runas") Edited June 12, 2014 by sanaldosya Link to comment Share on other sites More sharing options...
Developers Jos Posted June 12, 2014 Developers Share Posted June 12, 2014 Are these users listed in the Computers Administrators group or are they given in another way Admin access? When they are in the Administrators group you could enumerate the users in the group and see if the @username is in it. Jos Adele 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Adele Posted June 12, 2014 Author Share Posted June 12, 2014 How can I do? I don't know. Link to comment Share on other sites More sharing options...
Developers Solution Jos Posted June 12, 2014 Developers Solution Share Posted June 12, 2014 Something like this maybe: $oMyError = ObjEvent("AutoIt.Error", "ComError") If UserInGroup(@LogonDomain,@UserName,"Administrators") then msgbox(0,"Validate","User exists in specified groupname") Else msgbox(0,"Validate","User does NOT exist in specified groupname") EndIf Exit ; Check if User is in a group Func UserInGroup($Domain, $UserName, $InGroup) Local $objUser = ObjGet("WinNT://" & $Domain & "/" & $UserName) For $oGroup in $objUser.Groups If $oGroup.Name = $InGroup Then Return 1 EndIf Next Return 0 EndFunc ;COM Error function Func ComError() If IsObj($oMyError) Then $HexNumber = Hex($oMyError.number, 8) SetError($HexNumber) Else SetError(1) EndIf Return 0 EndFunc ;==>ComError Adele 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Adele Posted June 12, 2014 Author Share Posted June 12, 2014 Thank you very much. The issue has been resolved. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now