Steve,
Since you're running Windows XP, you can use WMI which I think is simpler
than setting up to use Windows API. Of course, you might open the VBE and
check under 'Tools > References' to see if you might not have the ability to
control some of the objects associated with VNC.exe.
Anyway, the subroutines below should get you going. Paste the publicly
declared variable as well as the two subroutines into a module after opening
VBE (Alt plus F11). Since I didn't have VNC.exe to test on, the subroutine
is set to launch a new notepad.exe process when you run the subroutine,
LaunchApp(), and then terminate that process when you run QuitApp(). After
you test with notepad, go into the LaunchApp() subroutine and edit the line
beginning with "strApp =" to point to your exe rather than notepad. Since
VNC.exe probably isn't in your system path, you will want to include the
full path statement along with the file name.
_________________________________________
Public intProcessID As Integer
Sub LaunchApp()
strApp = "Notepad.exe"
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create(strApp, Null, Null, intProcessID)
Set objProcess = Nothing
End Sub
Sub QuitApp()
Dim objWMIService
Dim colProcessList
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where ProcessID = " & intProcessID & "")
For Each objProcess In colProcessList
objProcess.Terminate
Next
End Sub
_________________________________________
Steve