Cancel Windows Shutdown Process


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Cancel Windows Shutdown Process

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Cancel Windows Shutdown Process

    [Originally posted by Eric Cranston]

    OK, I am trying to cancel a system shutdown, so basically a user clicks :start>shutdown computer: and this code that I am trying to write kills the shutdown process, acting like the user never clicked shutdown.* I'll take anything that'll work vb6 or vb .net (both would be great), anyways I am stuck, I can get programs to shutdown the computer, but the only way I've found to stop the computer from shutting down is by hitting cancel when programs ask to save something, so how do I cancel the shutdown process with my program?!

    Thank you in advance, sorry for going on and on

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Cancel Windows Shutdown Process

    [Originally posted by m.posseth]

    i have to go to work in a few minutes so first the VB6 vrsion :-)


    i could show you how to acomplish this with subclassing and reading registry values

    however this hould also work

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    * * If UnloadMode = vbAppWindows Then ' we're shutting down
    * * * * If MsgBox("Stop shutdown?", vbYesNo) = vbYes Then
    * * * * * * Cancel = True ' to stop shutdown
    * * * * End If
    * * End If
    End Sub

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Cancel Windows Shutdown Process

    [Originally posted by Eric Cranston]

    I'm not at home so I can't try it right now, but will that work if I get rid of the message box, I want to do it without user interaction, and I hope (not sure if possible) that I cna also get it to stop force shutdowns (these are shutdowns that simply kill programs rather then go though there unload processes), anyways thanks

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Cancel Windows Shutdown Process

    [Originally posted by m.posseth]

    hmmmm

    it works .... if you just remove the message box lines

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    * * If UnloadMode = vbAppWindows Then ' we're shutting down
    * * * * * * * * * Cancel = True ' to stop shutdown
    '* * * * * End If
    end sub



    hmmmm this wil help a bit in acomplishing your task

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Select Case UnloadMode
    Case vbAppWindows: Cancel = True
    Case vbAppTaskManager: Cancel = True
    Case vbFormOwner: Cancel = True
    End Select
    * *
    * *
    *
    End Sub


    but if the user is a administrator on the machine and uses the taskmanager twice in a row to try to kill the process windows will terminate the process ( after giving a warning screen )

    hmmm it should be much harder to stop if you made your proggy invissible in the taskmanager ( or run as a service )


    however it is an will always be possible to write a proggy that can kill a runing process if the user that is logged on to the computer has administrative priviliges* * ( and this is how it should be in my opinion )



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center