$launch and /xrun aren't included in mIRC. they are an external aliases, that use a COM object called Wscript.Shell to launch applications.

The Run method is rather flexible. it allows specifying some windows attributes (hidden, minimized, maximized...), and can also be configured to wait for the program to "return" (the script won't continue until the application is closed), which is a very useful feature.

The regex is just to make the code shorter... it's for verifying the /xrun switches (-h, -n, -m, -rN).

After using /comopen to connect to an object, $comerr is to be checked, and if it has positive value the script must stop.

The $launch code simply connects to the WScript.Shell object, checks for no errors then calls the Run method. the returned value, 0 or 1, will be placed in %r, which will be returned to the user after the COM connection is closed.