windows - Start programs via command-line, but only if not already running - Super User

PHOTO EMBED

Sun Dec 25 2022 08:22:29 GMT+0000 (Coordinated Universal Time)

Saved by @savabeh191

# If there isn't a running process that contains "lync"...
if (!((Get-Process | select ProcessName).ProcessName | where {$_ -like "*lync*"}))
{
    # Find the executable somewhere in program files (x86), and run it.
    &(where.exe /R "C:\Program Files (x86)\Microsoft Office" "lync.exe")
}
content_copyCOPY

https://superuser.com/questions/654088/start-programs-via-command-line-but-only-if-not-already-running