|
-
Nov 3rd, 2007, 06:57 AM
#1
Thread Starter
Hyperactive Member
[2005] Shutdown Help Needed!
I need to change the shudown on my computer so that when the shutdown button is clicked it stops the shutdown, runs my application and then shuts down the computer when my application has finished.
I've been thinking about having an application running all the time in the background and then cataching the shutdown command and stopping it, then running my application and then shutting down.
Does anyone have any code that can help with this please?
Thanks in advance.
------
KNXRB
Last edited by knxrb; Nov 3rd, 2007 at 07:03 AM.
-
Nov 3rd, 2007, 07:46 AM
#2
Re: [2005] Shutdown Help Needed!
You can do this by two method. One is in the Form1_FormClosing and check for the
Code:
e.CloseReason=CloseReason.WindowsShutDown
and to the job there.
Another method you can use the system events to detect the shutdown
Code:
'Add two command buttons
Imports Microsoft.Win32
Imports System.EventArgs
Imports System
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
AddHandler SystemEvents.SessionEnding, AddressOf ShutDownDetect
End Sub
Public Sub ShutDownDetect(ByVal sender As Object, ByVal e As EventArgs)
'Detect Shutdown and Do your job her
Me.Text = "Shutdown in Progress"
'Do your stuff here
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RemoveHandler SystemEvents.TimeChanged, AddressOf ShutDownDetect
End Sub
Hope this helps.
Please mark you thread resolved using the Thread Tools as shown
-
Nov 3rd, 2007, 08:42 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] Shutdown Help Needed!
thanks. will try it later!
-
Nov 3rd, 2007, 02:00 PM
#4
Re: [2005] Shutdown Help Needed!
Why does your app need to be run before the shutdown?
The Systemevents is your best bet since you state your app isnt running at the time.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 5th, 2007, 04:19 AM
#5
Thread Starter
Hyperactive Member
Re: [2005] Shutdown Help Needed!
It will be a backup thing copying changed files from one path to another. This needs to run before it shuts down so that I don't lose any of the data I have changed since logging in.
-
Nov 5th, 2007, 04:22 AM
#6
Re: [2005] Shutdown Help Needed!
Well then try just coding in the save stuff to be called from the Closing event since it really doesnt matter what the reason is, just need to save it upon closing.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 6th, 2007, 04:09 AM
#7
Thread Starter
Hyperactive Member
Re: [2005] Shutdown Help Needed!
I can't do that as the computer will just shutdown the backing up process and turn off. I can't start another thing as it shuts down.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|