‘ Mit VB-Script PID eines Prozesses ermitteln

process = “notepad.exe”
strComputer = “.”

Set objNet = CreateObject(“WScript.Network”)
src = objNet.UserName

pid = GetPID
msgbox pid ‘ PID des Prozesses mit VBScript ausgeben

Function GetPID
Set objwmi = GetObject(“winmgmts:\\” & strComputer)
wql = “Select * from Win32_Process Where Name = ‘” & process & “‘” ‘alle notepad.exe Prozesse die laufen herausfiltern’

Set objProzesse = objwmi.ExecQuery(wql)

For Each objProzess In objProzesse
objProzess.GetOwner notepaduser ‘username der notepad.exe bestimmen’
If notepaduser = src Then ‘notepad.exe, welche zum jeweiligen PC gehört, herausfiltern’
GetPID = objProzess.ProcessID
Exit Function
End If
Next

GetPID
End Function


Leave a Comment


You must log in to post a comment.