Jump to content

Invoke an Action Upon User: Switch User, Log Off, Stand By, Turn Off, Restart..?


 Share

Recommended Posts

I need to Invoke an Action Upon a User: Switch User, Log Off, Stand By, Turn Off, Restart..

So when the user executes any of those tasks a certain action will happen like send a key or kill a process Ect..

Can anything like this be done..??

Shutdown() function?

When the words fail... music speaks.

Link to comment
Share on other sites

so how can I determine what the user does though..??

I want to send a key to a certain window when the user does any of these actions: Switch User, Log Off, Stand By, Turn Off, Restart..

You can do following:

Go to Start, Run, gpedit.msc

after that: Computer configuration, Windows Settings, Scripts (Startup/Shutdown).

You put the scripts you want to run on shutdown/reboot there... :)

for Logoff you go under:

User Configuration, Windows Settings, Scripts (Logon/Logoff).

Edited by skysel
Link to comment
Share on other sites

You can do following:

Go to Start, Run, gpedit.msc

after that: Computer configuration, Windows Settings, Scripts (Startup/Shutdown).

You put the scripts you want to run on shutdown/reboot there... :)

for Logoff you go under:

User Configuration, Windows Settings, Scripts (Logon/Logoff).

That doesn't distinguish the shutdown type.

Link to comment
Share on other sites

From this forum http://www.vbforums.com/showthread.php?t=502073 ...

Add system power mode event handlers to the load event on your app:

Code:

'add the handlers for the system standby, resume, and shutdown AddHandler Microsoft.Win32.SystemEvents.PowerModeChanged, AddressOf PowerModeChanged AddHandler Microsoft.Win32.SystemEvents.Sessionending, AddressOf Sessionending

Then simply set up events to match:

Code:

Private Sub PowerModeChanged(ByVal sender As System.Object, _ ByVal e As Microsoft.Win32.PowerModeChangedEventArgs) Select Case e.Mode Case Microsoft.Win32.PowerModes.Resume 'windows is resuming from sleep Case Microsoft.Win32.PowerModes.Suspend 'goodnite windows End Select End Sub Private Sub Sessionending(ByVal sender As System.Object, _ ByVal e As Microsoft.Win32.SessionendingEventArgs) Select Case e.Reason Case Microsoft.Win32.SessionendReasons.Logoff 'logoff Case Microsoft.Win32.SessionendReasons.SystemShutdown 'shutdown End Select End Sub

This is for VBScripts.. I guess using Scriptomatic you could figure out for Autoit?

Edited by skysel
Link to comment
Share on other sites

can Scriptomatic convert that into Autoit?

Im not to familiar with doing such a thing..

No. Scriptomatic doesn't "convert" anything and furthermore it only generates WMI scripts.

You cannot "capture" the click of the shutdown buttons because you cannot intervene with the shutdown process once it has been triggered, unless there is some kind of callback registered.

Link to comment
Share on other sites

Maybe this thread contains some useful info for you

#607489

At least regarding the power-down functions. Intercept and prevent them and react as you like. Guess there are similar ways for log-off events etc...

Regards

Edit: Lol, 30 seconds to slow :)

Edited by KaFu
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...