Project

General

Profile

Actions

Bug #3486

closed

$comcall returns unknown command

Added by westor (GR) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Scripting
Target version:
Start date:
06/08/2017
Due date:
% Done:

0%

Estimated time:
Operative System:
All
Regression:
No

Description

Hello,

I was trying to execute that code, but after debugging it says that the problem is into the $comcall and the script stopping working while leaving the com object open.

alias wmm_download {
  if ($isid) || (!$1) || (!$2) || (!$3) { return }
  if ($1 == -c) {
    var %callback = $gettok($1-,2,34)
    var %url = $gettok($gettok($1-,3,34),1,32)
    var %file = $gettok($1-,4,34)
    var %com = $gettok($gettok($1-,5,34),1,32)
    var %r = $iif($comerr,1,$com(%com).result)

    if ($com(%com)) { .comclose %com }
    if (%r == -1) { %callback 1 S_OK %url $qt(%file) }
    elseif (%r == 1) { %callback 0 UnKnown_ComErr %url $qt(%file) }
    elseif (%r == 2) { %callback 0 IE6+_Needed %url $qt(%file) }
    elseif (%r == 3) { %callback 0 Connect_Error %url $qt(%file) }
    elseif (%r == 4) { %callback 0 Newer_ActiveX_Needed %url $qt(%file) }
    elseif (%r == 5) { %callback 0 Writefile_Error %url $qt(%file) }
    else { %callback 0 Unknown_Error %url $qt(%file) }
  }
  elseif ($1 !== -c) {
    var -s %callback = $gettok($1-,1,34)
    var -s %url = $gettok($gettok($1-,2,34),1,32)
    var -s %file = $gettok($1-,3-,34)
    var -s %com = wmm_download $+ $wmm_random $+ .vbs
    var -s %s = $wmm_temp $+ %com
    var -s %n = $left(%com,-4)

    .fopen -ox %n $qt(%s)

    .fwrite -n %n on error resume next
    .fwrite -n %n   set C = CreateObject("MSXML2.SERVERXMLHTTP.6.0")
    .fwrite -n %n   if (err.number <> 0) then
    .fwrite -n %n     err.clear
    .fwrite -n %n   set C = CreateObject("MSXML2.SERVERXMLHTTP.3.0")
    .fwrite -n %n   if (err.number <> 0) then
    .fwrite -n %n     err.clear
    .fwrite -n %n   set C = CreateObject("MSXML2.SERVERXMLHTTP")
    .fwrite -n %n   if (err.number <> 0) then
    .fwrite -n %n     err.clear
    .fwrite -n %n   set C = CreateObject("MSXML2.XMLHTTP.6.0")
    .fwrite -n %n   if (err.number <> 0) then
    .fwrite -n %n     err.clear
    .fwrite -n %n   set C = CreateObject("MSXML2.XMLHTTP.3.0")
    .fwrite -n %n   if (err.number <> 0) then
    .fwrite -n %n     err.clear
    .fwrite -n %n   set C = CreateObject("MSXML2.XMLHTTP")
    .fwrite -n %n   if (err.number <> 0) then 
    .fwrite -n %n     err.clear
    .fwrite -n %n   set C = CreateObject("XMLHttpRequest")
    .fwrite -n %n     if (err.number <> 0) then wscript.quit(2)
    .fwrite -n %n   end if
    .fwrite -n %n end if
    .fwrite -n %n end if
    .fwrite -n %n end if
    .fwrite -n %n end if
    .fwrite -n %n end if
    .fwrite -n %n C.open "GET", $qt(%url) $+ , false
    .fwrite -n %n C.send 
    .fwrite -n %n if (err.number <> 0) then wscript.quit(3)
    .fwrite -n %n set O = createobject("adodb.stream")
    .fwrite -n %n if (err.number <> 0) then wscript.quit(4)
    .fwrite -n %n O.type=1 
    .fwrite -n %n O.mode=3 
    .fwrite -n %n O.open 
    .fwrite -n %n O.write C.responsebody 
    .fwrite -n %n O.savetofile $qt(%file) $+ ,2
    .fwrite -n %n if (err.number <> 0) then wscript.quit(5)
    .fwrite -n %n O.close
    .fwrite -n %n Set oFso = CreateObject("Scripting.FileSystemObject") : oFso.DeleteFile Wscript.ScriptFullName, True
    .fwrite -n %n wscript.quit(-1)

    .fclose %n

    .comopen %com WScript.Shell
    if ($lines(%s) !== 41 || $comerr || !$comcall(%com,wmm_download -c $qt(%callback) %url $qt(%file),run,1,bstr*,$qt(%s),uint,1,bool,true)) { goto error }
    return
  }
  :error
  if ($error) { echo 4 -a ERROR: $error | reseterror }
  if ($com(%com)) { .comclose %com }
}

Actions

Also available in: Atom PDF