C
cj
My program shuts itself down and reboots the pc it's running on at
2:00am twice a week and has been doing so without fail for over a year.
But twice in the past month it's been found running in the AM with an
unhandled exception on the screen. As best I can tell this exception
occurs while it's trying to reboot the pc. This has me thinking it
might be nice to have it do a reboot whenever it has an unhandled
exception but then again I'm sure it's the rebooting that's causing the
exception. If I put the try catch code around the reboot code
Dim WMIService, Computer As Object
WMIService =
GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}")
For Each Computer In WMIService.InstancesOf("Win32_OperatingSystem")
Computer.Win32Shutdown(2 + 4, 0) 'reboot
Next
then if it throws an exception it will not reboot and the program will
be left running but nonfunctional as everything was stopped just before
the reboot code--which is actually worse than getting the unhandled
exception.
Can I put this reboot code in the unhandled exception event for my
application as well and if in the form closing event. If it throws an
exception in the form closing event or anywhere else I'm not catching
them it would then try to reboot or reboot again?
What if the code in the unhandled exception event throws and exception?
2:00am twice a week and has been doing so without fail for over a year.
But twice in the past month it's been found running in the AM with an
unhandled exception on the screen. As best I can tell this exception
occurs while it's trying to reboot the pc. This has me thinking it
might be nice to have it do a reboot whenever it has an unhandled
exception but then again I'm sure it's the rebooting that's causing the
exception. If I put the try catch code around the reboot code
Dim WMIService, Computer As Object
WMIService =
GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}")
For Each Computer In WMIService.InstancesOf("Win32_OperatingSystem")
Computer.Win32Shutdown(2 + 4, 0) 'reboot
Next
then if it throws an exception it will not reboot and the program will
be left running but nonfunctional as everything was stopped just before
the reboot code--which is actually worse than getting the unhandled
exception.
Can I put this reboot code in the unhandled exception event for my
application as well and if in the form closing event. If it throws an
exception in the form closing event or anywhere else I'm not catching
them it would then try to reboot or reboot again?
What if the code in the unhandled exception event throws and exception?