Protool VBScript Prozess aktiv

demmy86

Level-2
Beiträge
202
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
Hallo zusammen,

ich habe ein kleines Problem und zwar suche ich schon eine weile eine Möglichkeit aus Protool Pro heraus zu überprüfen ob eine Anwendung im Hintergrund gestartet ist. Protool läuft auf einem normalen Windows PC mit XP als Betriebssystem. Gibt es in VBS eine Funktion zum überprüfen ob eine .exe gestartet ist?

MfG demmy
 
Code:
set service = GetObject ("winmgmts:")

for each Process in Service.InstancesOf ("Win32_Process")
	If Process.Name = "notepad.exe" then
		wscript.echo "Notepad running"
		wscript.quit
	End If
next
wscript.echo "notepad not running"

Quelle.

Disclaimer: Habe es nicht selber getestet. Weiss nicht ob es funzt innerhalb von Protool RT.
 
Zuviel Werbung?
-> Hier kostenlos registrieren
Hallo,

Danke erst mal. Der Code Funktioniert aber leider nicht mit Protool,
ich habe es aber inzwischen geschafft einen funktionierenden Code zu schreiben.

hier ist er:

Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sProcessName[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sComputer[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] oWmi[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] oShell[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] colProcessList[/SIZE]
[SIZE=2]sProcessName = "Notepad.exe"[/SIZE]
[SIZE=2]sComputer = "." [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]' nutze "." für einen lokalen PC[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] oWmi = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Ab hier könnte eine Schleife folgen[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] colProcessList = oWmi.ExecQuery("Select * from Win32_Process Where Name = '" & sProcessName & "'")[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] colProcessList.Count = 0 [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]ExeStatus[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]ExeStatus[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Ende der Schleife[/COLOR][/SIZE]
[/COLOR][/SIZE]

Es kann ein beliebiger Prozess überwacht werden, welcher mit "sProcessName" festgelegt wird und die variable ExeStatus gibt in meinen Fall den Status des Prozesses zurück!
Der Code kann und muss natürlich noch auf eigene Bedürfnisse angepasst werden.

MfG
demmy :)
 
Zurück
Oben