Jump to content

Find Administrator and Guest username


Recommended Posts

Hi AutoIt scriptwriters! 

In some of windows operating systems, i saw that "Administrator" and "Guest" username in different languages are "Administradore" and "Gast" and etc. 

How to make a simple script to find Administrator and Guest username in different language in these systems?

Link to comment
Share on other sites

Another way:

#include <Security.au3>

Global $g_aComputerSID = _Security__LookupAccountName(@ComputerName)
    If @error Then Exit
ConsoleWrite(_GetAccountName($g_aComputerSID[0] & "-500") & @CRLF) ;~ Administator Account SID
ConsoleWrite(_GetAccountName($g_aComputerSID[0] & "-501") & @CRLF) ;~ Guest Account SID

Func _GetAccountName($_sAccountSID)
    Local $aAccountSID = _Security__LookupAccountSid($_sAccountSID, @ComputerName)
    Local $sAccoutName = @error = 0 And IsArray($aAccountSID) ? $aAccountSID[0] : ""
    Return $sAccoutName
EndFunc

 

Link to comment
Share on other sites

Don't bother with the Guest account name, 99% of the time that account is disabled and useless for any purposes.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

19 hours ago, Subz said:

Another way:

#include <Security.au3>

Global $g_aComputerSID = _Security__LookupAccountName(@ComputerName)
    If @error Then Exit
ConsoleWrite(_GetAccountName($g_aComputerSID[0] & "-500") & @CRLF) ;~ Administator Account SID
ConsoleWrite(_GetAccountName($g_aComputerSID[0] & "-501") & @CRLF) ;~ Guest Account SID

Func _GetAccountName($_sAccountSID)
    Local $aAccountSID = _Security__LookupAccountSid($_sAccountSID, @ComputerName)
    Local $sAccoutName = @error = 0 And IsArray($aAccountSID) ? $aAccountSID[0] : ""
    Return $sAccoutName
EndFunc

 

Thanks @Subz, your code worked properly for me!

Link to comment
Share on other sites

23 minutes ago, Colduction said:

No, It's useful for me when i want to grant a person with limited access, such as my brother! :X

Then just create an account. If it's REALLY for someone such as your brother then you know what the Guest account is called. I'm stating to smell fish here.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Developers

@Colduction,

Please give me a proper answer this time as you ignored me conveniently last time:

What are you really trying to do as this can't have anything to do with your brother and limiting access.
Do not ignore me this time as the will have repercussions. 

Jos

@ everybody else: Stay out until this thread is cleared again!

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

  • Developers

@Colduction,

As you elected not to answer yet, your posting capability is revoked until you change your mind and give me that answer.

Jos

 

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

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...