Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm wondering if I can use Application::ApplicationExit Event to cause my computer to shutdown if someone exits out of an app like Sticky Notes. Is here someone who could maybe provide some sample code on how I could do this? Very basic knowledge of coding. Your help is appreciated.

What I have tried:

I've tried to use Visual Studio Code to get a rough sketch, but this is all over my head.
Posted
Updated 9-Feb-18 5:14am
Comments
Richard Deeming 9-Feb-18 11:04am    
Why? It sounds like you're writing malware.
Giiman95 9-Feb-18 11:08am    
Not trying to write malware. I've got some idiot classmates who think it's funny to get on my account. Until I can get some more protection, this is was my next best idea.
F-ES Sitecore 9-Feb-18 11:10am    
Change your password.

If this was possible then malware would do it.
Richard Deeming 9-Feb-18 11:11am    
That's why it's always a good idea to lock your workstation whenever you leave it! :)

Win+L should work on most versions of Windows.
OriginalGriff 9-Feb-18 11:44am    
Even if you could, that wouldn't solve that problem: ALT+TAB or just the windows key will get them to any other app they want without closing anything.
As Richard says: if you don't want people using your account, don't leave your computer logged in and walk away.

1 solution

No.
The Application.ApplicationExit Event only fires when the current application is exiting, not when a different application is closed.
It is possible to detect when a different app closes, but as Richard has said what you are trying to do sounds like malware; it's difficult to think of a legitimate reason for doing this.
And we do not condone, support, or assist in the production of malicious code in any way, form, or manner. This is a professional site for professional developers.
 
Share this answer
 
Comments
Giiman95 12-Feb-18 9:53am    
Hi there. Thank you everyone for your suggestions. I want to go ahead an restate that my intention is not malicious. The problem I am running into was that those who had admin rights could simply go into control panel and remove my password. They were doing it when I wasn't in class. Their admin rights have been removed, but I am still thinking of adding something like a 2 factor authentication key of some sort and working on creating some new user groups to try and restrict more access. Thank you OriginalGriff for your solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900