...you can kill a program by using API functions or by using pskill from pstools.
to use API, by the way, you must know the classname and/or title of the program that you want to close...use spy.exe, if you want to get a class name of a program. run Calc.exe then try this:
option explicit
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Sub HideXWindow()
Dim Handle As Long
Dim lpClassName As String
Dim lpCaption As String
Const NILL = 0&
Const WM_SYSCOMMAND = &H112
Const SC_CLOSE = &HF060&
lpClassName = "SciCalc"
lpCaption = "Calculator"
'get handle for the window
'for unknown window caption use this line
Handle = FindWindow(lpClassName, vbNullString)
'for unknown class name use this line
Handle = FindWindow(vbNullString, lpCaption)
'for both known class name and caption use this line
Handle = FindWindow(lpClassName, lpCaption)
If Handle = 0 Then
Debug.Print "specified program is not running"
'some codes here to handle this or Exit Function
End If
'send message to close program(s)
Handle = SendMessage(Handle, WM_SYSCOMMAND, SC_CLOSE, NILL)
End Function
...For using PsKill, check out my previous thread thread222-531574
Now, you know how to shut down a program, i'm sure that you can handle the rest to restart a program.
Have Fun!