Jump to content

Need User name from System Account


 Share

Recommended Posts

Hello guys,

I want to know that how can i get the user name of currently active user from Service Account.

Did you even look in the help file?!

I just searched "system" in the help file and found this in 5 seconds...

@KBLayout Returns code denoting Keyboard Layout. See Appendix for possible values.

@OSLang

Returns code denoting OS Language. See Appendix for possible values.

@OSType

Returns "WIN32_NT" for NT/2000/XP/2003/Vista and returns "WIN32_WINDOWS" for 95/98/Me

@OSVersion

Returns one of the following: "WIN_2008", "WIN_VISTA", "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95"

@OSBuild

Returns the OS build number. For example, Windows 2003 Server returns 3790

@OSServicePack

Service pack info in the form of "Service Pack 3" or, for Windows 95, it may return "B"

@ProcessorArch

Returns one of the following: "X86", "IA64", "X64"

@ComputerName

Computer's network name.

@UserName

ID of the currently logged on user.

@IPAddress1

IP address of first network adapter. Tends to return 127.0.0.1 on some computers.

@IPAddress2

IP address of second network adapter. Returns 0.0.0.0 if not applicable.

@IPAddress3 IP address of third network adapter. Returns 0.0.0.0 if not applicable.

@IPAddress4 IP address of fourth network adapter. Returns 0.0.0.0 if not applicable.

@DesktopHeight

Height of the desktop screen in pixels. (vertical resolution)

@DesktopWidth

Width of the desktop screen in pixels. (horizontal resolution)

@DesktopDepth Depth of the desktop screen in bits per pixel.

@DesktopRefresh Refresh rate of the desktop screen in hertz.

Instant Lockerz Invite - www.instantlockerzinvite.co.uk
Link to comment
Share on other sites

Did you even look in the help file?!

I just searched "system" in the help file and found this in 5 seconds...

@KBLayout Returns code denoting Keyboard Layout. See Appendix for possible values.

@OSLang

Returns code denoting OS Language. See Appendix for possible values.

@OSType

Returns "WIN32_NT" for NT/2000/XP/2003/Vista and returns "WIN32_WINDOWS" for 95/98/Me

@OSVersion

Returns one of the following: "WIN_2008", "WIN_VISTA", "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95"

@OSBuild

Returns the OS build number. For example, Windows 2003 Server returns 3790

@OSServicePack

Service pack info in the form of "Service Pack 3" or, for Windows 95, it may return "B"

@ProcessorArch

Returns one of the following: "X86", "IA64", "X64"

@ComputerName

Computer's network name.

@UserName

ID of the currently logged on user.

@IPAddress1

IP address of first network adapter. Tends to return 127.0.0.1 on some computers.

@IPAddress2

IP address of second network adapter. Returns 0.0.0.0 if not applicable.

@IPAddress3 IP address of third network adapter. Returns 0.0.0.0 if not applicable.

@IPAddress4 IP address of fourth network adapter. Returns 0.0.0.0 if not applicable.

@DesktopHeight

Height of the desktop screen in pixels. (vertical resolution)

@DesktopWidth

Width of the desktop screen in pixels. (horizontal resolution)

@DesktopDepth Depth of the desktop screen in bits per pixel.

@DesktopRefresh Refresh rate of the desktop screen in hertz.

Thanks for your kind reply. I know very well about @Username macro.

i want to know that how can i get the ID of the currently logged on user, from System Account.

I am using Service PROCESS , and when ever i user @username macro it will retun me <b>"SYSTEM"</b>

hope so you will understand my problem.

73 108 111 118 101 65 117 116 111 105 116

Link to comment
Share on other sites

  • Developers

It could be that your question isn't clear... :)

Username of System account ?

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

It could be that your question isn't clear... :)

Username of System account ?

i have a service process, now i want the username of normal loged in account name.

bcoz if i use @username in service process it will give me System not the loged in User name.

hope so it will clear the concept.

Edited by Digisoul

73 108 111 118 101 65 117 116 111 105 116

Link to comment
Share on other sites

Maybe you need to grab the SID out of HKLM\software\Microsoft\windows NT\currentversion\winlogon, then compare it to the list of SID entries you'll find that loo like this: HK_Users\<SID>\software\microsoft\windows\currentversion\explorer\shell. Once you have a match I think it's easy to pull the username.

Not sure how helpful, but this command-line utility is related:

PsGetSid v1.43

Edit: Well, my registry doesn't quite look like what I expected. I only have a single user account defined. Searching "SID" here might get you something... or this might be somewhat useful:

Well-known security identifiers in Windows operating systems

Edited by Spiff59
Link to comment
Share on other sites

Thanks for your help guys but im not understatnding anything.

i have some question

1. where from i get these SID

2. how can i know that which user or Sid is currently Active ?

Thanks for your kind help.

73 108 111 118 101 65 117 116 111 105 116

Link to comment
Share on other sites

I think if you look under HKCU\Volatile Environment the strings in there should identify the logged-on user.

I already checked this key, its not valid when you run any process in System Account. :)

why this thing become a challenge for me? :)

any other possible solution ?

73 108 111 118 101 65 117 116 111 105 116

Link to comment
Share on other sites

This is a VB script to find the username of a user logged into a remote machine... perhaps someone can help you translate it to autoit:

strComputer = "atl-ws-o1"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 

Set colComputer = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
 
For Each objComputer in colComputer
    Wscript.Echo "Logged-on user: " & objComputer.UserName
Next

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

I already checked this key, its not valid when you run any process in System Account. :)

why this thing become a challenge for me? ^_^

any other possible solution ?

So you want to run a script as a service under the SYSTEM account, and have it track what user is logged in to the desktop?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Here's a translation, seems to work...

Dim $colComputer, $TargetComputer = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\" & $TargetComputer & "\root\cimv2")
If Not IsObj($objWMIService) Then MsgBox(1,"", "ObjGet error")
$colComputer = $objWMIService.ExecQuery("SELECT * from Win32_ComputerSystem")
For $objComputer in $colComputer
    MsgBox(1,"", $objComputer.UserName)
Next

Here at home I haven't any remote computer to try with, but am assuming if you have the rights, you could change the "." to a server name.

edit: a bit 'o cleanup

Edited by Spiff59
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...