Display logged in user on remote XP machine

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tbharber
Posts: 32
Joined: 17 Sep 2010 17:08

Display logged in user on remote XP machine

#1 Post by tbharber » 17 Sep 2010 21:26

I need a way to display the current logged in User ID based on the IP Address of a computer on my network. I know there are a billion utilities I can download to do this but this will be done on a work computer and they do not allow any additional software to be installed so this will need to be done from a batch file. It needs to basicly be something like "echo %username%" only do it to a remote computer.

I have Googled this topic all day any I can't come up with a solution that will work. A lot of people seem to recomend the "netstat" command for this but for some reason it does not show the User ID of the logged in user (it only the domain name). Another command I heard was the "systeminfo" command but it only displays the Registered Owners name.

Any other thoughts?

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Display logged in user on remote XP machine

#2 Post by orange_batch » 17 Sep 2010 22:18

I looked at this problem for a while and I didn't figure much out, but a possible solution would be...

A remote machine either needs the Scheduler service or Telnet service running, I'm not sure which would work or be better.

at /?

telnet /?

If your machines are running I think XP Pro or above, you should be able to get the current user with the WMIC command tool.

wmic /?

Or maybe

net user

would suffice. Systeminfo doesn't seem to display user information. Anyways, this is my favourite DOS reference, but it doesn't have information on everything. http://ss64.com/nt/

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: Display logged in user on remote XP machine

#3 Post by amel27 » 17 Sep 2010 23:52

Code: Select all

WMIC /Node:"192.168.1.21" ComputerSystem GET UserName|Find "\"
Last edited by amel27 on 18 Sep 2010 01:48, edited 1 time in total.

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Display logged in user on remote XP machine

#4 Post by orange_batch » 18 Sep 2010 00:10

Image

tbharber
Posts: 32
Joined: 17 Sep 2010 17:08

Re: Display logged in user on remote XP machine

#5 Post by tbharber » 18 Sep 2010 07:31

Nice amel27! I triend a bunch of combinations with the WMIC command but could not figure it out. So far this is the best solution I have seen to this problem. I was only able to test it at home and will give it a go on Monday when I get back to work.

I have two small issues. First is that it also gives back the computer name as well. For example when I run this on my home computer I get "MORDOR\Tim". Assuming the computer name can be different lengths how can I just extract the "Tim" part of that result?

The second I am kind of embaressed to ask because I am sure it is very easy. I am trying to display:

"Current Logged in User ID is: Tim".

I have tried to do this with the following:
echo Current Logged in User ID is: | WMIC /Node:"%ndnum%" ComputerSystem GET UserName|Find "\"

The problem is the WMIC command wants to put the result on the next line instead of next to "Current User is:" I have also tried the & symbol instead of the pipe with no luck.

Thoughts?

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: Display logged in user on remote XP machine

#6 Post by amel27 » 18 Sep 2010 10:09

Code: Select all

For /F "Tokens=2* Delims==\" %%i In (
'WMIC /Node:"192.168.1.21" ComputerSystem GET UserName /Value^|Find "="'
) Do Echo Current Logged in User ID is: %%j

tbharber
Posts: 32
Joined: 17 Sep 2010 17:08

Re: Display logged in user on remote XP machine

#7 Post by tbharber » 18 Sep 2010 11:56

Thanks again amel27! That did it perfectly!

Jess Selien
Posts: 13
Joined: 26 Sep 2012 12:08

Re: Display logged in user on remote XP machine

#8 Post by Jess Selien » 28 Aug 2013 15:59

tasklist /V /S %server% /FI "IMAGENAME eq explorer.exe"

Post Reply