P
Peter
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
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