Actions
Bug #5162
closed$comval() doesn't work in some cases
Start date:
10/04/2020
Due date:
% Done:
0%
Estimated time:
Operative System:
All
Regression:
No
Description
Hello,
I was trying to use the following code but i see that $comval() doesn't work correctly.
alias pid { if (!$isid) { return } var %r = $ticks $+ $rand(1111,9999) var %1 = pid_locator_ $+ %r var %2 = pid_services_ $+ %r var %3 = pid_result_ $+ %r if ($com(%1)) { .comclose $v1 } if ($com(%2)) { .comclose $v1 } if ($com(%3)) { .comclose $v1 } .comopen %1 WbemScripting.SWbemLocator if ($comerr) { goto end } if (!$com(%1,ConnectServer,3,dispatch* %2)) && ($comerr) { goto end } if (!$com(%2,ExecQuery,3,bstr,SELECT * FROM Win32_Process WHERE ExecutablePath = $qt($replace($mircexe,\,\\)),dispatch* %3)) && ($comerr) { goto end } if (!$com(%3,Count,3)) { goto end } var %res = $com(%3).result if (%res) { var %pid = $comval(%3,1,ProcessId) } :end if ($com(%1)) { .comclose $v1 } if ($com(%2)) { .comclose $v1 } if ($com(%3)) { .comclose $v1 } return $iif(%pid,$v1,0) }
The problem above is on line 22
if (%res) { var %pid = $comval(%3,1,ProcessId) }
It works if change that to:
if (%res) { var %pid = $comval(%3,1,ProcessId,0) }
- Thanks!
Updated by westor (GR) almost 4 years ago
forgot to mention that, The error message when fails is:
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Updated by Per Amundsen almost 4 years ago
- Status changed from Resolved to Closed
Actions