Typeperf: How to check if a Service/Proccess is currently running?

Raul Chiarella 21 Reputation points
2021-06-19T22:14:46.137+00:00

Hello there!

I would like to know the counter for typeperf used for monitoring a proccess/service status...

Example: typeperf "\Process(AnyDesk)\Is it running?"

I expect this command to return a True or False statement (1 or 0)
Is this possible to achieve using typeperf?

Thanks in advance!

Windows for business | Windows Server | User experience | Other
Windows for business | Windows Client for IT Pros | User experience | Other
{count} votes

Accepted answer
  1. MotoX80 36,401 Reputation points
    2021-06-19T22:56:45.51+00:00

    I'm sure that it's possible somehow with typeperf, but I think that Powershell would be a better tool to use.

     param ($ComputerName = "")
    
     $np = get-process -Name notepad -ComputerName $ComputerName -ErrorAction SilentlyContinue
     If ($np.count -eq 0) {
         "Notepad is not running."
     } else {
         "There are {0} instances of Notepad that are running." -f $np.Count
     } 
     try {
         $svc = Get-Service -Name LanmanServer -ComputerName $ComputerName -ErrorAction Stop
         if ($svc.Status -eq 'Running') {
             "LanmanServer is running." 
         } else {
             "LanmanServer is NOT running." 
         }
     } catch {
         "Error, the LanmanServer service is not defined."
     }
    

1 additional answer

Sort by: Most helpful
  1. Castorix31 90,686 Reputation points
    2021-06-21T14:16:41.663+00:00

    You can use Tasklist command and parse the result

    For example, test if Windows Defender service is running :

    tasklist /svc /fi "SERVICES eq Windefend"
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.