473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to run the execuatable before windows shutting down

Dear all,

I would like to know how to run the execuatable before windows shutting
down.
Here is my simple code:
Private Sub Command1_Click()
Shell "C:\abc.bat", vbNormalFocus
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbAppWindows Then
Shell "C:\abc.bat", vbNormalFocus
MsgBox "Finished!!"
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call Command1_Click
End Sub

When I click Command1, it works
When I shut down the Windows, the message box comes out but cannot
execute "abc.bat".
because after executed "abc.bat", a result file will be created.

Do any expert can help me?

Thanks

Sep 27 '06 #1
3 3162
Hello le****@gmail.com,

You'll have to cancel the shutdown, launch your app, and then initiate a
second shutdown.

This is NOT a good idea. shutting down a system is NOT the time to be launching
apps. Cancelling a user-requested shutdown is punishable by castration in
some places. Rethink your design.

-Boo
Dear all,

I would like to know how to run the execuatable before windows
shutting
down.
Here is my simple code:
Private Sub Command1_Click()
Shell "C:\abc.bat", vbNormalFocus
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbAppWindows Then
Shell "C:\abc.bat", vbNormalFocus
MsgBox "Finished!!"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call Command1_Click
End Sub
When I click Command1, it works
When I shut down the Windows, the message box comes out but cannot
execute "abc.bat".
because after executed "abc.bat", a result file will be created.
Do any expert can help me?

Thanks

Sep 27 '06 #2
le****@gmail.com wrote:
I would like to know how to run the execuatable before windows shutting
down.
Why?
What do you want this program to do?

When Windows shuts down, it can be quite harsh in its treatment of
running processes - have you ever seen the "End Now" dialog? You cannot
override that kind of behaviour.

Whatever it is you need to do, how about doing it the next time Windows
/starts up/? Just add a shortcut into the StartUp group. It's easier
to see what's going on and more reliable.

HTH,
Phill W.

Here is my simple code:
Private Sub Command1_Click()
Shell "C:\abc.bat", vbNormalFocus
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbAppWindows Then
Shell "C:\abc.bat", vbNormalFocus
MsgBox "Finished!!"
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call Command1_Click
End Sub

When I click Command1, it works
When I shut down the Windows, the message box comes out but cannot
execute "abc.bat".
because after executed "abc.bat", a result file will be created.

Do any expert can help me?

Thanks
Sep 27 '06 #3
Not sure if this will work for you, but you can assign a Shutdown script using
Group Policy.

<le****@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Dear all,

I would like to know how to run the execuatable before windows shutting
down.
Here is my simple code:
Private Sub Command1_Click()
Shell "C:\abc.bat", vbNormalFocus
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbAppWindows Then
Shell "C:\abc.bat", vbNormalFocus
MsgBox "Finished!!"
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call Command1_Click
End Sub

When I click Command1, it works
When I shut down the Windows, the message box comes out but cannot
execute "abc.bat".
because after executed "abc.bat", a result file will be created.

Do any expert can help me?

Thanks

Sep 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Jesper | last post by:
Does anyone know some c++ code for shutting down windows? I want to write a program using borland c++ builder to shut down windows. --
3
by: Shailesh S. Gokhale | last post by:
Hi All! Recently I installed mysql on a win98. Some 2 days after the installation the system started experiencing a problem shutting down. When shutting down the hard-disk kept spinning...
3
by: Claire | last post by:
Windows refuses to close down if my applications main form is hidden and there's a notify icon in the system tray. If I restore the form, then shutting down Windows succeeds. If I comment out the...
3
by: quilkin | last post by:
Hi When I use the WM_QUERYENDSESSION event to prevent closing of my app when Windows is shut down, I get the 'windows forms parking window' appearing which is very confusing for users. Any ideas...
2
by: Peter Meinl | last post by:
Restarting Windows seems not to fire the OnShutdown event in the Windows Service. Does not work on Windows XP SP2 and not on Windows 2003 Server SP1. OnStart and OnStop do work fine. Steps...
4
by: Markus Stoeger | last post by:
Hi, I have a problem with Application.Run() when Windows is shutting down. Please have a look at the copy&paste example program below. The application has no forms. It has only got a notify...
7
by: Mark | last post by:
It is possible from a .NET application to prevent Windows from shutting down? I understand that a .NET application can "know" that windows is initiating the process of to shutting down - but...
3
by: Chris Knievel | last post by:
Hi, i am trying to save some data in a excel spreadsheet, whenever the programm shuts down. Mostly this happens when a user is logging off or shuts the computer down. im am using the Private Sub...
1
by: =?Utf-8?B?SXp6eQ==?= | last post by:
I was wondering if anybody has seen the following error when shutting down a WIndows 2003 server before. Every time the server is shut down we receive the same BSOD. It recovers shortly and is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.