473,761 Members | 8,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Closing another application

I have scheduled programs that run overnight. One of them leaves a window
open and this stops other users opening the program. It is a third-party
application.

Can I write a vb .NET program to add to the schedule to close it? What
object can be used to reference another application?

TIA
--
Helen
May 26 '06 #1
5 21954
Try this

Private Sub KillExcel()

Dim myProcesses As Process
Dim myProcess As Process

myProcesses = Process.GetProc essesByName("EX CEL.EXE")
For Each myProcess In myProcesses
myProcess.Kill( )
Next

myProcesses = Nothing
myProcess = Nothing

End Sub

HTH

May 26 '06 #2
That's exactly what I need. I have tried it and it works.

Thanks.
--
Helen
"ar********@gma il.com" wrote:
Try this

Private Sub KillExcel()

Dim myProcesses As Process
Dim myProcess As Process

myProcesses = Process.GetProc essesByName("EX CEL.EXE")
For Each myProcess In myProcesses
myProcess.Kill( )
Next

myProcesses = Nothing
myProcess = Nothing

End Sub

HTH

May 26 '06 #3
<ar********@gma il.com> schrieb:
Private Sub KillExcel()

Dim myProcesses As Process
Dim myProcess As Process

myProcesses = Process.GetProc essesByName("EX CEL.EXE")
For Each myProcess In myProcesses
myProcess.Kill( )
Maybe it's better to use 'MyProcess.Clos eMainWindow()' instead of calling
the 'Kill' method.
myProcesses = Nothing
myProcess = Nothing


Setting the variables to 'Nothing' here doesn't make sense and doesn't need
to be done as it's done automatically when the method is left.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 26 '06 #4
cj
Herfried,

I'm thinking of using this process too. If I use
MyProcess.Close MainWindow will the command wait for the other programs
to end before it returns or will it just issue a command to them to
close then move on to the next program?

Here's why, I'm looking to reboot the pc at 2am each day (you might have
read some of my questions on rebooting via program) and would like write
a program to do this but I want it to shutdown any other programs that
might be running before rebooting the pc.
Herfried K. Wagner [MVP] wrote:
<ar********@gma il.com> schrieb:
Private Sub KillExcel()

Dim myProcesses As Process
Dim myProcess As Process

myProcesses = Process.GetProc essesByName("EX CEL.EXE")
For Each myProcess In myProcesses
myProcess.Kill( )


Maybe it's better to use 'MyProcess.Clos eMainWindow()' instead of
calling the 'Kill' method.
myProcesses = Nothing
myProcess = Nothing


Setting the variables to 'Nothing' here doesn't make sense and doesn't
need to be done as it's done automatically when the method is left.

Jun 1 '06 #5
cj
I can get it to kill all processes just as I can list them below

Dim myprocesses() As Process
Dim myprocess As Process

myprocesses = Process.GetProc esses
For Each myprocess In myprocesses
Debug.WriteLine (myprocess.Proc essName)
Next

but the problem is I wouldn't want to kill all the processes. That
would be a problem. I want to exit all "applicatio ns" currently running.

Then again the whole idea probably will not work as many of the apps
written are home grown and probably would either not respond to a
shutdown request or would close abruptly w/o finishing up what they are
doing. And MS apps don't even need closing as the act of shutting down
windows causes them to shut down. How do they know windows is closing?
cj wrote:
Herfried,

I'm thinking of using this process too. If I use
MyProcess.Close MainWindow will the command wait for the other programs
to end before it returns or will it just issue a command to them to
close then move on to the next program?

Here's why, I'm looking to reboot the pc at 2am each day (you might have
read some of my questions on rebooting via program) and would like write
a program to do this but I want it to shutdown any other programs that
might be running before rebooting the pc.
Herfried K. Wagner [MVP] wrote:
<ar********@gma il.com> schrieb:
Private Sub KillExcel()

Dim myProcesses As Process
Dim myProcess As Process

myProcesses = Process.GetProc essesByName("EX CEL.EXE")
For Each myProcess In myProcesses
myProcess.Kill( )


Maybe it's better to use 'MyProcess.Clos eMainWindow()' instead of
calling the 'Kill' method.
myProcesses = Nothing
myProcess = Nothing


Setting the variables to 'Nothing' here doesn't make sense and doesn't
need to be done as it's done automatically when the method is left.

Jun 1 '06 #6

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

Similar topics

2
359
by: Job Lot | last post by:
I am wondering how Application.Exit, Me.Dispose and End are different when it comes to closing an application (File --> Exit menu) Thanks
5
2260
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here is to ensure that no child window can close while it is in a state where user entered information can be lost. I have just noticed that while the Closing event is caught if I click the X on the child window, it is not caught if I click the X on...
2
3871
by: Michael C | last post by:
Hi all, Receiving an error when closing an application that contains the AxWebBrowser component, whenever I close the app: ".NET-BroadcastEventWindow.1.0.5000.0.4: myApplication.exe - Application Error The exception unknown software exception (0xc0020001) occurred in the application at location 0x77e6d756. Click on OK to terminate the program"
2
1943
by: Strahimir Antoljak | last post by:
Is it possible to prevent terminate the application (and how). I am aware of preventing the closing application, but here I mean on more violent cases when user tries to kill (terminate) the application process in the Windows Task Manager. Thanks, -- Strah @ Langan
6
10433
by: Giojo | last post by:
Hello guys! I can't resolve this problem.. I want my programm in c# working with only console if there are some parameters, but if someone make double-click on the exe I want to start the graphic GUI without the black console on background.. Now I check if there are some parameters and if there aren't parameters I run the GUI (with the black console that remain..). If I choose Windows application on Visual Studio, when I run the...
6
2098
by: ahmad.humyn | last post by:
I have an application in which the main form goes something like: public frmMain() { frmA frm = new frmA(); frm.show(); this.hide(); } Now that the control has been passed to frmA, how do I close the
0
1323
by: esutcliffe | last post by:
Greetings, How do I close MS Outlook after use reviews the email before sending? I open MS Outlook application and create an email. But at the end of the function I do not Quit Outlook as I want the user to review the email before sending. Once the email is sent, an instance of Outlook is left hanging out there open. I am not sure where or how to place the "Quit" once the
1
2430
by: architavakharia | last post by:
Hi all, I am getting crash in ntdll.dll just after CDialog::OnOK(); function. It is not getting crashed everytime. Application is multithreaded, but it is after i have added new thread. In that I am using vector list and also maintaining the criticalsection and thread proc close event. Now, in constructor i m setting NULL to all handles and initialize critical section and for stopping thread i m setting close event and my thread is comeout...
0
2770
by: =?Utf-8?B?RGFsZSBXaWxsaWFtcw==?= | last post by:
Everyone: When working with winform applications, you could check the reason for closing the window. As in this example: private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { if (CloseApplication())
0
2462
by: raddrummer | last post by:
Hi there, I have 2 issues happening that I could really use some help with. These are probably really easy.... 1) I'm using VB in Access to generate a Visio org chart and then save it to my machine. I'm running into syntax issues near the bottom of the page for the Target of the new org chart. I've tried: objAddOn2.Run "/QUIET=True /NAVBAR=False /SEARCH=true /TARGET="C:\Documents and Settings\SLozano\My Documents\OrgChart.htm"" but get an...
0
10115
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9905
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9775
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8780
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6609
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5229
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.