Did you change #channel in my script?
If so, what does this return in mIRC?
//echo -a $os $version $beta $md5($mircexe,2) $script(0) $dll(0) $com(0)
Edit:
And Riamus' code is correct, because he describes as situation where you disable auto-join. His script then checks if ($chan != #channel), meaning if (#invitedchannel ISNOT #channel).