07-21-2006 02:45 AM
07-21-2006 03:02 AM
C:\WINDOWS\system32\taskkill.exe /F /IM DIAdem.exe
See M$ help for parameter usage or use -? parameter| Matthias Alleweldt Project Engineer / Projektingenieur | Twigeater? |
07-21-2006 04:58 AM
07-21-2006 08:53 AM
Option Explicit
If IsDIAdemRunning() Then
Call MsgBox( "At least one DIAdem is running!" )
Else
Call MsgBox( "No DIAdem at all!" )
End If
Function IsDIAdemRunning()
Dim oWshShell
Dim oExec
' Execute via Shell Object
Set oWshShell = CreateObject("WScript.Shell")
Set oExec = oWshShell.Exec( "C:\windows\system32\tasklist.exe /FI ""IMAGENAME eq DIAdem.exe""")
' wait until tasklist is finished
Do While oExec.Status = 0
Pause(1)
Loop
' no Standard Output -> no DIAdem running
IsDIAdemRunning = Len(oExec.StdOut.ReadAll) <> 0
End Function
A better solution might be possible via WMI. | Matthias Alleweldt Project Engineer / Projektingenieur | Twigeater? |
07-22-2006 12:43 AM
Option Explicit
Dim oWMI
Dim oProcessList
Dim oProcess
' Get WMI for the local computer
Set oWmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
' Query process list
Set oProcessList = oWmi.ExecQuery("Select * from Win32_Process Where Name = 'DIAdem.exe'")
' Print running processes count
Call MsgBox( oProcessList.Count & " DIAdem.exe instances are running")
' Terminate all runing processes
For Each oProcess in oProcessList
oProcess.Terminate()
NextMatthias
| Matthias Alleweldt Project Engineer / Projektingenieur | Twigeater? |