简体   繁体   中英

How can i verify if a process is already running on powershell?

i have the following code

Start-Process -windowstyle minimized "C:/xampp/xampp-control.exe"

There is a way to know if process is already running?

One way to do this is to get the process ID of the process (use the -PassThru parameter of Start-Process ) and then you can see if the process exists by ID. Example:

$processId = (Start-Process notepad -PassThru).Id
if ( Get-Process -Id $processId -ErrorAction SilentlyContinue ) {
   "Process is running"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM