Forum Discussion
Identify a running script in Get-Process and script PID
- Feb 28, 2024
A script isn't a process. It's uncompiled code that runs inside of an interpreter - a term you won't hear often in this era.
So, there is no concept of a process id for a script, as the process - and therefore the process id - is implicitly that of the interpreter running the script.
It's no different from earlier scripting iterations like those from the Windows Scripting Host (such as JavaScript and VBScript), where in that case, the process id would have been that of the Windows Scripting Host (be that WScript.exe or CScript.exe).
Is there a particular challenge you're trying to solve or are you just curious about the topic?
Cheers,
Lain
A script isn't a process. It's uncompiled code that runs inside of an interpreter - a term you won't hear often in this era.
So, there is no concept of a process id for a script, as the process - and therefore the process id - is implicitly that of the interpreter running the script.
It's no different from earlier scripting iterations like those from the Windows Scripting Host (such as JavaScript and VBScript), where in that case, the process id would have been that of the Windows Scripting Host (be that WScript.exe or CScript.exe).
Is there a particular challenge you're trying to solve or are you just curious about the topic?
Cheers,
Lain
LainRobertson wrote:
There is no concept of a process id for a script, as the process - and therefore the process id - is implicitly that of the interpreter running the script.
This is very clarifying.
Is there a particular challenge you're trying to solve or are you just curious about the topic?
No, it was just out of curiosity: as mentioned before, I looked for a similarity between bash (or ksh, or other Unix-like shells) and PowerShell. But they are different as regards this aspect.
I was also looking for this to obtain the status of the script execution, after the system exits from sleep mode.