How to script log in and log out on windows xp

妖精的绣舞 提交于 2019-12-08 08:30:29
latkin

Well here's how you would log 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 log someone in, it seems tougher. Take a look here and here.

You can log in a user with the AutoAdminLogon feature.

To store the password in encrypted rather than plaintext form, see here.

After configuring automatic logon, you will need to reboot the computer in order to make the logon happen. You can bypass the need for a reboot by using a custom GINA, although this is a bit complicated and does not work on Vista or later.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!