Look up logged on user on Win32

Posted on 2002-05-10
Last Modified: 2010-03-05

Is there some way in perl to look up who is logged on to remote machine.  I want to be able to specify a machine and lookup who is logged onto it.  This is on Window NT/2000.



Question by:jvieira
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 51

Expert Comment

ID: 7002964
system("net.exe name-of-pdc session");

Accepted Solution

sstouk earned 100 total points
ID: 7003590
The net session command would not work in Workgroup.

There are tho ways of identifying who is logged in to the LOCAL system:

$name = Win32::AdminMisc::GetLogonName();
Using the AdminMisc module
$user = Win32::LoginName();

To do the task, you could create a small script, which creates a file with the current login name of the user.
You can access the file with any remote access and have a look at it.

But if systems are on the domain, the best way is to use the "net session" command as "ahoffmann"  gave you an example of.

LVL 51

Expert Comment

ID: 7004649
in a workgroup you cannot "logon" to a remote server, just "connect" shares
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 7011758

To clarify something.  The perl program will be running on WindowsNT/2000 but it will be quering machine that are Windows NT/2000/98.  Perl is not installed on all the machine which is why I want to query it remotely.  I don't think the net session program exists on 98.  Win32::LoginName only works on the local machine I want who is logged in on a remote machine.
LVL 51

Expert Comment

ID: 7011941
install rshd.exe from NT's ResKit. AFAIK it works for 98 too.
Then you can use
   rsh remotehost net.exe session
or for Win98
   rsh remotehost echo %USER%

To find out which OS it is use:
   rsh remotehost echo %OS%
which retuns Windows_NT on NT and nothing on Win98.

Check the commands in a shell (cmd.exe), then it should be simple to use them within perl with system() or backticks (if your perl support backticks on NT)

Author Comment

ID: 7011950
That requires me to go to every machine and install the rshd.exe application.  If I'm already at their machine I can just lookup who is logged on.  There must be something either in the registry or something else that I can look at from a remote machine and see who is logged on without ever having to go to the machine or install anything on it.

I can get disk and network info remotely now all I need is user info.
LVL 51

Expert Comment

ID: 7011973
> There must be something either ..
hmm, laugh or cry ;-) Remeber: it's M$ !!

Think you're clued to M$ proprietary things like SMP, but that requires installation either, IIRC.

Author Comment

ID: 7022522
Since the answer is "it can't be done." I'll award the points to sstouk.  His answer does not require using anything but perl even though it won't do it remotely.  

Thanks anyway,


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question