$exe() identifier

By ^WeSt on Jul 06, 2018

You can check for a running .exe progress on tasklist via that identifier.

Usage:

$exe(name.exe)[.total]
(If the exe that your specified exist then it will return $true otherwise will be returned $false)

.total (optional) = Will return the total exe programs that running with that name you specified.

Examples:

//echo -a Exe: $exe(mirc.exe)
//echo -a Exe: $exe(mirc.exe).total

Code:

alias exe {
  if (!$1-) { return }
  var %com1 = exe1_ $+ $ticks
  var %com2 = exe2_ $+ $ticks
  var %com3 = exe3_ $+ $ticks
  .comopen %com1 WbemScripting.SWbemLocator
  if ($comerr) { goto error }
  .comclose %com1 $com(%com1,ConnectServer,3,bstr,.,bstr,root\cimv2,dispatch* %com2)
  .comclose %com2 $com(%com2,ExecQuery,3,bstr,SELECT * FROM Win32_Process WHERE Name = $qt($1),dispatch* %com3)
  noop $regsubex($str(.,$comval(%com3,0)),/(.)/g,$comval(%com3,0,0))
  :error
  if ($com(%com1)) { .comclose $v1 }
  if ($com(%com2)) { .comclose $v1 }
  if ($com(%com3)) { .comclose $v1 }
  var %st = $regml(0)
  if (%st) { return $iif($prop && $prop == total,%st,$true) }
  elseif (!%st) { return $iif($prop && $prop == total,0,$false) }
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.