How to script login and logout on windows xp

I found several posts on this site and on the internet describing how to log out of the current user, but how can I log a specific user?

Logging out of the system (cygwin) can be done like this:

echo "\n" | powershell -ExecutionPolicy RemoteSigned "(gwmi Win32_OperatingSystem).Win32Shutdown(0)"

      

+1


source to share


2 answers


Well, here's how you would register out a specific user:

function getsessionid($username, $server)
{
   query session $username "/SERVER:$server" |?{$_ -match "$userName\s+(\d+)\s"} |%{ $matches[1] }
}

$id = getsessionid john db123.contoso.net
logoff $id /SERVER:db123.contoso.net

      



To enroll someone in it seems tougher. Take a look here and here .

0


source


You can log in using the AutoAdminLogon function .

To store the password encrypted and not clear text, see here .



After setting up automatic login, you need to restart your computer for the login to occur. You can get around the need for a reboot with a custom GINA, although this is a bit tricky and doesn't work in Vista or later.

0


source







All Articles