ProcessID Property (Windows Script Host)
The process ID (PID) for a process started with the WshScriptExec object.
Syntax
Object.ProcessID
Parameters
- Object
WshScriptExec object.
Remarks
You can use the ProcessID property to activate an application (as an argument to the AppActivate method).
Legacy Code Example
The following code uses the ProcessID property to activate the calculator and notepad applications.
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"
function delayedSendKeys(str)
{
WScript.Sleep(100);
WshShell.SendKeys(str);
}
var WshShell = new ActiveXObject("WScript.Shell");
var oCalc = WshShell.Exec("calc");
var 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");