ReaImDown Posted May 23, 2007 Share Posted May 23, 2007 How would I go about checking to see if any other users are logged in on the computer, then if so, log them off? any help is muchly appreciated [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 23, 2007 Share Posted May 23, 2007 How would I go about checking to see if any other users are logged in on the computer, then if so, log them off? any help is muchly appreciated This finds the user: $strComputer = "." ; Change this with remote computer name $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colComputer = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") $RET = "" For $objComputer In $colComputer $RET &= $objComputer.UserName Next MsgBox(64, "Users logged on:", $RET) The SHUTDOWN.EXE utility will cause remote logoff or shutdown. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ReaImDown Posted May 23, 2007 Author Share Posted May 23, 2007 (edited) This finds the user: $strComputer = "." ; Change this with remote computer name $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colComputer = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") $RET = "" For $objComputer In $colComputer $RET &= $objComputer.UserName Next MsgBox(64, "Users logged on:", $RET) The SHUTDOWN.EXE utility will cause remote logoff or shutdown. cool, thanks alot...muchly appreciated PsaltyDS. is it impossible to log off every user but the current one then? hmm that only appears to show the current user logged on, Edited May 23, 2007 by ReaImDown [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 23, 2007 Share Posted May 23, 2007 hmm that only appears to show the current user logged on,That is correct. Outside of MS Terminal Server, Windows is a single user OS as far as the console logon goes. Perhaps you meant "users having a network session connected" or something like that? What, exactly, did you mean by "...any other users are logged in"? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ReaImDown Posted May 23, 2007 Author Share Posted May 23, 2007 That is correct. Outside of MS Terminal Server, Windows is a single user OS as far as the console logon goes. Perhaps you meant "users having a network session connected" or something like that? What, exactly, did you mean by "...any other users are logged in"? on windows XP, I can log onto my account, then click "Start/Log Off/Switch Users" and my girlfriend can log on...when I press CTRL+ALT+Delete and goto users, it shows the people logged on (myself - active and my girlfriend - disconnected) I want the program to log off all users that say "Disconnected"...which is anyone that isnt the current user. [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
cryn Posted May 23, 2007 Share Posted May 23, 2007 I think what your talking about is fast user switching which lets you have the accounts still logged in below i supplied a link to micro$osft how to disable that feature.http://support.microsoft.com/kb/279765 Link to comment Share on other sites More sharing options...
tAKTelapis Posted May 23, 2007 Share Posted May 23, 2007 Yup, definitely a feature worth disabling. On that note, it has piqued my interest. If you wanted to do this on a terminal server? I know you can run tsadmin, and view the info. and it can connect to the remote systems, is there a WMI call to this service? Link to comment Share on other sites More sharing options...
ReaImDown Posted May 24, 2007 Author Share Posted May 24, 2007 Yup, definitely a feature worth disabling.On that note, it has piqued my interest. If you wanted to do this on a terminal server?I know you can run tsadmin, and view the info.and it can connect to the remote systems, is there a WMI call to this service?thank you all for your interest so, there is no way autoit can log off the users on its own? [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 24, 2007 Share Posted May 24, 2007 on windows XP, I can log onto my account, then click "Start/Log Off/Switch Users" and my girlfriend can log on...when I press CTRL+ALT+Delete and goto users, it shows the people logged on (myself - active and my girlfriend - disconnected) I want the program to log off all users that say "Disconnected"...which is anyone that isnt the current user.I see what you mean. I wouldn't call that multi-user because all users except one have all their processes suspended and saved to disk/page file. But that's nit picky. I can find WMI objects for remote shutdown and logoff, but they don't have any fields for specify a suspended and stored user. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ReaImDown Posted May 24, 2007 Author Share Posted May 24, 2007 (edited) I see what you mean. I wouldn't call that multi-user because all users except one have all their processes suspended and saved to disk/page file. But that's nit picky. I can find WMI objects for remote shutdown and logoff, but they don't have any fields for specify a suspended and stored user. same problem I have...when I use the shutdown command, if more than 1 user is logged on...it asks me if I wish to log off, (which stops the autoit code from executing...) even if I cannot log off the users with autoit...is there a way it can detect if more than 1 is on? Edited May 24, 2007 by ReaImDown [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
herewasplato Posted May 24, 2007 Share Posted May 24, 2007 ...(which stops the autoit code from executing...)Can you change your code to just deal with that window if it comes up - like a Winwait with a timeout? [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
ReaImDown Posted May 24, 2007 Author Share Posted May 24, 2007 (edited) Can you change your code to just deal with that window if it comes up - like a Winwait with a timeout?no, because when the popup comes up...all coding stops I believe, I tried making the program click "YES" and it didnt do anything...know what...I lied...lol, I am a horrible person lol...well, horrible coder neways...I left out a line of code before which compromised it -.-'...well, suppose that'll work for now...thanks alot...muchly appreciated...ty again to all those who helped, (if you come up with a way to make it detect all users logged on, please post it Randy S. Edited May 24, 2007 by ReaImDown [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
herewasplato Posted May 24, 2007 Share Posted May 24, 2007 no, because when the popup comes up...all coding stops I believe, I tried making the program click "YES" and it didnt do anything...Thanks, I did not know that. (I've never scripted for a system with that feature enabled.)I have Googled and read somethings in hopes of helping in this thread, but I've not found a solution just yet. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
ReaImDown Posted May 24, 2007 Author Share Posted May 24, 2007 (edited) Thanks, I did not know that. (I've never scripted for a system with that feature enabled.) I have Googled and read somethings in hopes of helping in this thread, but I've not found a solution just yet. crap...I lied again lol heres my coding, and this doesnt work shutdown(1) WinWaitActive("Windows", "Other people are logged on to this computer.") tooltip("worked") sleep(1000) send("N")oÝ÷ Û^æ¬ò.±ëaÇ(uëaz{kÉ©Ý(}øÂ䱫¢+Ø)]¥¹]¥ÑÑ¥Ù ÅÕ½Ðí]¥¹½ÝÌÅÕ½Ðì°ÅÕ½Ðí=Ñ¡ÈÁ½Á±É±½½¸Ñ¼Ñ¡¥Ì½µÁÕÑȸÅÕ½Ðì¤)ѽ½±Ñ¥À ÅÕ½ÐíݽÉÅÕ½Ðì¤)ͱÀ ÄÀÀÀ¤)͹ ÅÕ½Ðí8ÅÕ½Ðì what do these do? 4 = Force 8 = Power down Edited May 24, 2007 by ReaImDown [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
herewasplato Posted May 24, 2007 Share Posted May 24, 2007 (edited) ...what do these do?4 = Force8 = Power downGo to a CMD window and type/enter this:shutdown /?Edit: I think that 4 = Forces running applications to close without warning...I'm not sure if 8 = Shutdown the computerChange the WinWaitActive to just WinWait and add a 5 second timeout...if that does not work, then this thread shows a way to have one script launch another script: http://www.autoitscript.com/forum/index.php?showtopic=22531You could have that child script do the shutdown while the main script waits for the window....or maybe just use /AutoIt3ExecuteLine to run the shutdown line... Edited May 24, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
ReaImDown Posted May 24, 2007 Author Share Posted May 24, 2007 Go to a CMD window and type/enter this:shutdown /?Edit: I think that 4 = Forces running applications to close without warning...I'm not sure if 8 = Shutdown the computerChange the WinWaitActive to just WinWait and add a 5 second timeout...if that does not work, then this thread shows a way to have one script launch another script: http://www.autoitscript.com/forum/index.php?showtopic=22531You could have that child script do the shutdown while the main script waits for the window....or maybe just use /AutoIt3ExecuteLine to run the shutdown line...WinWait("Windows", "Other people are logged on to this computer.", 10000)doesnt work [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
herewasplato Posted May 24, 2007 Share Posted May 24, 2007 WinWait("Windows", "Other people are logged on to this computer.", 10000)doesnt work that is 10,000 seconds [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
ReaImDown Posted May 24, 2007 Author Share Posted May 24, 2007 that is 10,000 secondsI know...plenty of time to work lol... shutdown(5) works...it skips the other users are logged on message...force + shutdown...thanks for the help guys lol...god that was a headache lol [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
herewasplato Posted May 24, 2007 Share Posted May 24, 2007 Glad that you found your solution. A short timeout was meant to be little more than a sleep... but not quite the same. ...have fun... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now