Jump to content

How would I...


Recommended Posts

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

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 by ReaImDown
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

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

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

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

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

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

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 by ReaImDown
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

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 by ReaImDown
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

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

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 by ReaImDown
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

...what do these do?

4 = Force

8 = Power down

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 computer

Change 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=22531

You 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 by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

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 computer

Change 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=22531

You 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

that is 10,000 seconds

I 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...