473,386 Members | 1,842 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,386 software developers and data experts.

Closint processes

I have a VB 2008 program, AutoBackup3, converted from VB 6, to back up my
files, using Migo Backup Pro, & to do several manipulations with the
resulting backup files.

Migo Backup Pro is called using a statement:
Backup = Process.Start(PathFile, Arguments)
After the backup program is finished, it 'leaves behind' the three processes
listed in the the Dim procNameA() ... statement below.

When I execute the subroutine below, it executes just fine, except, none of
the three processes are actualluy being closed. They are still running
aftert my appplication, AutoBackup3, closes.

What am I doing wrong?

Subroutine Listing:
'Closes specified processes
Sub CloseProcesses2()

Dim procNameA() As String = {"NBKCtrl", "NSEngine", "NMSAccessU"}
Dim procName As String
Dim myProcesses As Process()
Dim myProcess As Process

Try

For Each procName In procNameA
' Get all instances of the named process running on the
local computer
myProcesses = Process.GetProcessesByName(procName)
If Not myProcesses Is Nothing Then
Debug.WriteLine("Number of instances = " &
myProcesses.Count)
For Each myProcess In myProcesses
If myProcess.MainWindowTitle <"" Then
myProcess.CloseMainWindow()
End If
myProcess.Close()
Next
Else
Debug.WriteLine("Process " & procName & " not found")
End If
Next

Catch ex As Exception
Dim strProgram, strMsg As String
strProgram = "CloseProcesses2"
strMsg = "An error occurred during closing of processes." &
vbCrLf & vbCrLf _
& "Error Description: " & ex.Message
MsgBox(strMsg, vbExclamation + vbOKOnly, strProgram)
End Try

End Sub
Any Assistance will be appreciated.

Peter
Sep 11 '08 #1
2 915
>What am I doing wrong?

Process.Close doesn't to anything to close the actual process, it just
invalidates the Process object instance (more or less the same as the
Dispose method). If Process.CloseMainWindow doesn't do what you need
(if there's no window to close or it doesn't make the application
exit) you're basically left with Process.Kill which is kind of an
extreme way to force a process to terminate with no opportunity to
clean up properly.

Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Sep 13 '08 #2
Thxs, that clarifies things. I wish the help files would spell out those
things.
of the three apps I'm trying to kill, two don't have a main window. So, I
guess I'll have to use the Kill method.

Actually, Migo PCBackup Pro, the software I'm using, should close its own
apps as the backup process comes to an end, but they don't.

Peter
"Mattias Sjögren" wrote:
What am I doing wrong?

Process.Close doesn't to anything to close the actual process, it just
invalidates the Process object instance (more or less the same as the
Dispose method). If Process.CloseMainWindow doesn't do what you need
(if there's no window to close or it doesn't make the application
exit) you're basically left with Process.Kill which is kind of an
extreme way to force a process to terminate with no opportunity to
clean up properly.

Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Sep 14 '08 #3

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

Similar topics

1
by: Markus Franz | last post by:
Hi. I created a little script: for currenturl in sys.argv: pid = os.fork() if pid == 0: signal.alarm(10) do_something() # placeholder for the download and print routine
6
by: Bob Swerdlow | last post by:
My application starts up a number of processes for various purposes using: self.popen = popen2.Popen3("/usr/local/bin/python -O "myscript.py") and then shuts them down when appropriate with...
15
by: Dirk Reske | last post by:
Hello, why doesn't this code work correctly? private int GetCpuUsage(Process proc) { DateTime time1,time2; TimeSpan timediff; double cpu1,cpu2,cpudiff;
9
by: Abhishek Srivastava | last post by:
Hello All, In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process per appliction pool. Each worker process is dedicated...
4
by: AN | last post by:
Greetings, We make an ASP.NET web application and we host it for our customers. We have provisioned hardware and hope to be able to service around 200 customers on this hardware. The web...
35
by: Carl J. Van Arsdall | last post by:
Alright, based a on discussion on this mailing list, I've started to wonder, why use threads vs processes. So, If I have a system that has a large area of shared memory, which would be better? ...
3
by: xxs | last post by:
I have writen some codes as follow: #include <windows.h> #include <tlhelp32.h> #include <stdio.h> // Forward declarations: BOOL GetProcessList( ); BOOL ListProcessModules( DWORD dwPID...
1
by: jazon | last post by:
Let me start by saying this for an Operating Systems class. No, I don't expect the work to be done for me. The assignment is as follows: To be honest, I feel like a fish out of water, like...
6
by: Tim Arnold | last post by:
I have a bunch of processes to run and each one needs its own working directory. I'd also like to know when all of the processes are finished. (1) First thought was threads, until I saw that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.