Dim strProcessName, strCommandLineA, strCommandLineB, objWSH, objWMI, colProcessList, objProcess, boolA
strProcessName = "Programm.exe"
strCommandLineA = "C:\Programm.exe"
strCommandLineB = "D:\Programm.exe"
Folgendes als .vbs abspeichern funktioniert einwandfrei
Set objWSH = WScript.CreateObject("WScript.Shell")
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = objWMI.ExecQuery("Select * from Win32_Process Where Name = '" & strProcessName & "'")
For Each objProcess In colProcessList
If InStr(LCase(objProcess.CommandLine), LCase(strCommandLineA)) <> 0 Then boolA = True
objProcess.Terminate()
Next
If boolA Then
objWSH.Run """" & strCommandLineB & """"
Else
objWSh.Run """" & strCommandLineA & """"
End If
Set objWSH = Nothing
Set objWMI = Nothing