mIRC Homepage
Posted By: j0k3r COM object not working.. - 24/10/04 05:05 PM
Code:
alias cmd {
  var %f = c:\ $+ $1 $+ .txt
  if ($com($1)) { .comclose $1 }
  .comopen $1 WScript.Shell
  if (!$comerr) {
    .comclose $1 $com($1,Run,3,bstr,$+(%,comspec%) /c $1 $2- > %f,uint,0,bool,true)
  }
  loadbuf -s %f
  .remove %f
}


This is supposed to perform a task using DOS and output it to a file, and then get shown in status.

The problem I receive is:

* /loadbuf: unable to open 'c:\netstat.txt'
Posted By: tidy_trax Re: COM object not working.. - 24/10/04 05:17 PM
It works fine for me using /cmd echo %username%, check that the command you're trying is a valid DOS command.
Posted By: j0k3r Re: COM object not working.. - 24/10/04 05:25 PM
/cmd echo %username% didn't work for me, either.

is this for certain OS' or something?

* /loadbuf: unable to open 'c:\echo.txt'
Posted By: tidy_trax Re: COM object not working.. - 24/10/04 05:29 PM
Shouldn't be, try opening cmd.exe (or msdos) and typing "echo %comspec%" without the quotes, it should echo the full path to cmd/msdos, if it does, I can't see why it wouldn't work.
Posted By: j0k3r Re: COM object not working.. - 24/10/04 05:33 PM
It does return the path to cmd.exe, but it still doesnt work frown
Posted By: tidy_trax Re: COM object not working.. - 24/10/04 05:39 PM
Try this then:

Code:
alias cmd {
  if ($com($1)) { .comclose $1 }
  .comopen $1 WScript.Shell
  if (!$comerr) {
    var %comspec = $com($1,ExpandEnvironmentStrings,3,bstr,$+(%,comspec%))
    %comspec = $com($1).result
    .comclose $1
    run -n %comspec /c $1- > $1.txt
    .timer 1 2 loadbuf -s $1.txt
    .timer 1 2 .remove $1.txt
  }
}


It's a messy workaround, but it might work for you. smile
Posted By: j0k3r Re: COM object not working.. - 24/10/04 05:47 PM
uh i think i found the problem..

i put echo $comerr before if (!$comerr) and it echos 1

Code:
.comopen $1 WScript.Shell
isn't working
Posted By: Armada Re: COM object not working.. - 25/10/04 09:39 AM
If its just netstat your looking for i use this.
Code:
 
alias netstat {
  write -c netstat.txt
  var %a = run $+ $ticks 
  .comopen %a WScript.Shell 
  if $comerr { return }
  if $com(%a,Run,3,bstr,cmd.exe /c netstat > " $+ $mircdirnetstat.txt",uint,0,bool,true) {
    .comclose %a
  }
  .comclose %a
}
 
© mIRC Discussion Forums