473,473 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Process.CloseMainWindow()

Is there a way to force a window to close without displaying a popup asking:
"Windows cannot end this program....If you choose to end the program
immediately, you will lose any unsaved data."

This is a process I am calling and controlling through the code, but I
defiantely want the process to close the window without any user
intervention. Can I force this to close?

The Process.CloseMainWindow() does not seem to have any overrides that will
simulate the "End Now" button.

Thanks
Andy
Feb 24 '06 #1
3 5650
On Fri, 24 Feb 2006 09:55:30 -0800, Andy wrote:
Is there a way to force a window to close without displaying a popup asking:
"Windows cannot end this program....If you choose to end the program
immediately, you will lose any unsaved data."

This is a process I am calling and controlling through the code, but I
defiantely want the process to close the window without any user
intervention. Can I force this to close?


That would be Process.Kill() then if you want to kill the process. Not very
clean though. You could try to close it normally, then wait a few seconds
for it to close and kill it eventually if it really refuses to close by
itself. Sounds better to me.
Feb 24 '06 #2
Hi,

Process.Kill is your answer, note that this does nothing to allow the
process to terminate in a nice way.

Process.CloseMainWindow should be prefered.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Andy" <An**@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
Is there a way to force a window to close without displaying a popup
asking:
"Windows cannot end this program....If you choose to end the program
immediately, you will lose any unsaved data."

This is a process I am calling and controlling through the code, but I
defiantely want the process to close the window without any user
intervention. Can I force this to close?

The Process.CloseMainWindow() does not seem to have any overrides that
will
simulate the "End Now" button.

Thanks
Andy

Feb 24 '06 #3
Thanks for the suggestion, but the odd thing is: when I use Process.Kill,
the main window does not close, but remains open, which is why I was trying
to use the CloseMainWindow() method.

For some reason: when I issue a Process.Kill, the process itself is killed,
but the user window remains open, which is causing an issue.

Thanks
Andy

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Process.Kill is your answer, note that this does nothing to allow the
process to terminate in a nice way.

Process.CloseMainWindow should be prefered.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Andy" <An**@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
Is there a way to force a window to close without displaying a popup
asking:
"Windows cannot end this program....If you choose to end the program
immediately, you will lose any unsaved data."

This is a process I am calling and controlling through the code, but I
defiantely want the process to close the window without any user
intervention. Can I force this to close?

The Process.CloseMainWindow() does not seem to have any overrides that
will
simulate the "End Now" button.

Thanks
Andy


Feb 24 '06 #4

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

Similar topics

2
by: T | last post by:
How do you catch the "Exited" event when a process is terminated. In the following code sample the "myProcess_Exited" event is never called. Any help would be appreciated. using System; using...
2
by: Shawn Hogan | last post by:
I'm trying to open an instance of the default browser and browse to a URL. I'm seeing an issue with the process class where if i execute my process using this code Dim p As Process = New Process...
5
by: Tedmond | last post by:
Dear all, How can I get all the titles of all openning windows? I found a API in win32 that called EnumWindows() but it returns only the windows handles, not titles. How can I get the list just...
7
by: Samantha | last post by:
Hello , I am developping a program for Win98 plateform, and I am stucking with a problem, hope you can help me. I have a program running 2 process : - One process running the Xcopy.exe -...
5
by: Brett | last post by:
How do I gracefully kill a process than restart it? The process Image Name is known. Thanks, Brett
2
by: Danny | last post by:
I have converted serveral vb6 applications to vb.net. One of these applications originally would stop one of my applications by using the findwindow api and using the sendmessage api to close the...
1
by: tascien | last post by:
Hi guys, I would like to be able to open a program and close it wright within vb... ' this one works... Process.Start("c:\someProgram.exe") Thread.sleep(5000) ' this one doesn't !...
2
by: paragshravagi | last post by:
Hi. I am trying to open a process for msinfo32.exe using C#. I successfully started it. But after that I need to wait for 10 seconds for some other operations during which this process gets...
1
by: Rick | last post by:
Can anyone tell me how to set the printer using the process class in VB.net, I've tried everything, it always goes to the default printer. My Code: Dim pathToExecutable As String =...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.