Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

PLEASE HELP

How can I log off remote users from a list of host names that was given?And log back on again using my credentials?

I have about 1400 WinXP PCs that some dumb engineer have logged on to them and left!
I have a super account that I can log on to ay PC and log off anyone out. Doing 1400 PC's manually will be tidious job and I don't have access to Active Directory.

Is there a Perl Module that will enable me to log off whom ever is logged on and will log any user back on again if I need to?

Thanks very much indeed..

Replies are listed 'Best First'.
Re: Forcing remote users to log off.
by tachyon (Chancellor) on Jul 30, 2004 at 15:54 UTC

    If you have a look at Win32::KillProcess you will see some Perl code that lets you connect to remote machines and do whatever you have perms for. Probably the easiest way is to sutdown and reboot the remote machine which will force a logoff by default. I don't know why you would actually want to logon to a machine you are not sitting in front of. You can manipulate them without doing that per se.

    The Microsoft Windows 2000 Resource Kit and Microsoft Windows NT Resource Kit supply a shutdown.exe utility that you can use to shut down or reboot the local or a remote machine. I'm sure you can find it on the web ;-) This utility also lets you configure how to handle hung applications. For example:

    C:\> shutdown \\morpheus /r /t:15 "Astalavista Baby"

    cheers

    tachyon

Re: Forcing remote users to log off.
by waswas-fng (Curate) on Jul 30, 2004 at 15:35 UTC
    Take a look at this. you can use perl to automate sending the commands to the remote computers.


    -Waswas
Re: Forcing remote users to log off.
by CountZero (Bishop) on Jul 30, 2004 at 18:29 UTC
    Ask that "dumb" engineer how he managed to log-on to 1400 computers and use his system to log-off?

    If it is a good system don't forget to take out a patent for it before he does!

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Forcing remote users to log off.
by meetraz (Hermit) on Aug 02, 2004 at 18:11 UTC
    Since Windows XP logons are treated as terminal sessions, you can use the terminal services API to log users off. Something like this:

    use strict; use Win32::Lanman; my $target = 'client01'; Win32::Lanman::WTSLogoffSession($target, 0); # See also: # WTSEnumerateSessions() # WTSQuerySessionInformation() # WTSDisconnectSession()