mIRC Homepage
Posted By: MrPeepers Com object - 27/09/03 05:51 PM
Would the comopen command work with a .bat? If so what would I use for the id? I run a bat to ftp a html file to my site, and I have to use the /run command but I have to run a shortcut to the file, and Id like to close the bat window when its finished. Any ideas on how to help?
Posted By: Iori Re: Com object - 27/09/03 06:36 PM
You can use this to run the bat, and then perform other commands. e.g. //batrun | echo 4 -a * Done!
* Done! will be echoed AFTER the bat has finished.
Code:
alias batrun {
  var %a = $ticks
  .comopen %a WScript.Shell
  if !$comerr { .comclose %a $com(%a,Run,3,bstr,[color:blue]filename.bat[/color],uint,0,bool,true) }
}


edit
Note: It is "silent" - you will not see any sign of the bat or DOSbox. smile
Posted By: MrPeepers Re: Com object - 27/09/03 06:40 PM
Why am I setting my ticks to a variable and wouldnt i want to do a comclose when it is done?
Posted By: Iori Re: Com object - 27/09/03 06:45 PM
setting %a = $ticks is simply to give the com a unique name. There IS a comclose, check the last line
if !$comerr { .comclose %a $com(%a,Run,3,bstr,filename.bat,uint,0,bool,true) }
. smile
Posted By: MrPeepers Re: Com object - 27/09/03 06:47 PM
ahhhhhh sorry, thank you Ill test it out
Posted By: cold Re: Com object - 29/09/03 12:57 AM
Weird thing, I think mIRC should evaluate $com before calling /comclose.. but this won't close it, as I've tested.
Posted By: Iori Re: Com object - 29/09/03 04:42 AM
Closes for me no problems.
When you pass mIRC a "/command $identifier" line it first evaluates the $identifier before executing the /command. You can see this by typing "//run $mircini", obviously $mircini is evaluated to 'path\mirc.ini' (or whatever.ini) or the command simply couldn't work. smile
Posted By: cold Re: Com object - 29/09/03 04:59 AM
Well, I know this, this is the behaviour I said it should have, but it doesn't close here.. is there any other reason for it not closing that I don't know of?
Posted By: Iori Re: Com object - 29/09/03 05:13 AM
None that I know of. Check that your .bat file actually completes and closes.
Posted By: Online Re: Com object - 29/09/03 12:29 PM
Deleting the dot (.) that precedes the comopen and comclose commands turns off the "silent" mode, letting you know whether the object was successfully opened or closed.

I don't know what's the version of your OS, but assuming it works the same for all of them, lets try what I did on Win98. Open your mIRC folder, locate the batch file and double-click on it (the file doesn't have to contain meaningful commands yet, just add some echo's). What happens when it finishes running? Is the DOS window automatically closed?

If it stays open, that's why your $com() never returned. You must get it to close itself once the process is finished. To accomplish that, do either:
  • Go to the file properties, select the 'Program' tab and check the 'Close on exit' option (note: that will create a .pif file on the same folder)
  • Add a single CLS command at the end of the file without a CRLF after it (since /write always ends the line with a CRLF you'll have to type it manually or use binary writing, /bwrite file.bat -1 CLS).
For details, read this tutorial under the section "Closing a DVM window automatically".
Posted By: cold Re: Com object - 29/09/03 08:32 PM
Yeah, that was the problem, it didn't close automatically. Doing what you've suggested solved it. Thanks for the help, very much appreciated smile
Posted By: Iori Re: Com object - 01/10/03 07:05 AM
I didn't realize win98 didn't auto close dos boxes when .bat files complete, good to know but its a bit retarded I think. smile
© mIRC Discussion Forums