mIRC Home    About    Download    Register    News    Help

Print Thread
#87715 21/06/04 11:57 AM
Joined: Jun 2004
Posts: 7
I
indiko Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Jun 2004
Posts: 7
Is it possible to run a program from mIRC and start certain actions after that program is finished depending on the exit value?

#87716 21/06/04 01:04 PM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
alias exitcode {
  • var %a = wsh $+ $ticks
    .comopen %a Wscript.Shell
    if !$comerr {
    if $com(%a,Run,1,bstr,$1,uint,5,bool,true) {
    var %code = $com(%a).result
    }
    .comclose %a
    return %code
    }
}

Usage: $exitcode(<program file>)

This is a modified version of /xrun.

A couple of links: Introduction to COM, WshShell.Run() Method.

#87717 21/06/04 01:38 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
This will pause mIRC while the program is running if I understand correctly...
Since I'm interested in this sort of thing: is there also a way to just let the script (and mIRC) continue and have the return code returned (erm, yeah) to mIRC when the program finishes? Or have mIRC request the return code, like have a timer that checks if the program is still running and have it request it when the program has ended?

#87718 21/06/04 05:06 PM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
$exitcode won't freeze your mIRC, but it's better to use $comcall here.

alias part1 {
  • var %a = wsh $+ $ticks
    .comopen %a Wscript.Shell
    !.echo -q $comcall(%a,part2,Run,1,bstr,ping.exe 127.0.0.1,uint,5,bool,true)
}

alias part2 {
  • echo -a Exit code: $com($1).result
    .comclose $1
}

#87719 21/06/04 06:11 PM
Joined: Jun 2004
Posts: 7
I
indiko Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Jun 2004
Posts: 7
That helps, tyvm.

Surely better than including sendmessage support in such a small helper program. wink


Link Copied to Clipboard