AFAIK - no. If you _call_ an application from a script using WshExec,
you can get a PID that way, then save it to a file which a script
later called by the app itself would check. Here's an example (drawn
from the docs) on using PIDs. I am usually in the situation of having
one script call another; in that case, if I need to have a script know
its own PID, I actually pass the path of the pidfile to the script
being called as an argument.
Sub delayedSendKeys(str)
WScript.Sleep 100
WshShell.SendKeys str
End Sub
Dim WshShell, oCalc, oNotepad
Set WshShell = CreateObject("WScript.Shell")
Set oCalc = WshShell.Exec("calc")
Set oNotepad = WshShell.Exec("notepad")
WScript.Sleep 500
WshShell.AppActivate oCalc.ProcessID
delayedSendKeys "1{+}1~"
delayedSendKeys "^C"
delayedSendKeys "%{F4}"
WshShell.AppActivate oNotepad.ProcessID
delayedSendKeys "1 {+} 1 = ^V"
Quote:
> Does anyone know if it is possible for a script to know the process
ID of
> the calling application?
> Thanks,
> John Hucker MCSE.