Jump to content
Sign in to follow this  
Digisoul

Need User name from System Account

Recommended Posts

Digisoul

Hello guys,

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


73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites
furrycow

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

Share this post


Link to post
Share on other sites
Digisoul

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

Share this post


Link to post
Share on other sites
Digisoul

Hello is there any topic in this forum about my requirements.

i tried to search but me faild :)

so plz help me.


73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites
Digisoul

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

Share this post


Link to post
Share on other sites
Spiff59

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

Share this post


Link to post
Share on other sites
Digisoul

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

Share this post


Link to post
Share on other sites
Anteaus

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

Share this post


Link to post
Share on other sites
Digisoul

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

Share this post


Link to post
Share on other sites
SpookMeister

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]

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
Digisoul

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?

:)

Ah! thanks GOD some1 understand what i want.

have you any Idea ?


73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites
Spiff59

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.