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?
Display logged in user on remote XP machine
Moderator: DosItHelp
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: Display logged in user on remote XP machine
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/
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/
Re: Display logged in user on remote XP machine
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.
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: Display logged in user on remote XP machine
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?
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?
Re: Display logged in user on remote XP machine
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
Re: Display logged in user on remote XP machine
Thanks again amel27! That did it perfectly!
-
- Posts: 13
- Joined: 26 Sep 2012 12:08
Re: Display logged in user on remote XP machine
tasklist /V /S %server% /FI "IMAGENAME eq explorer.exe"