Running mIRC on a Headless Linux Server


This guide assumes you are using Windows and have access to a remote server running Linux. If you don't have access to a remote server, I recommend setting up and running a cheap Digital Ocean 512mb droplet running Debian 8.2 x32.

From within Windows, make sure you have all of the following software installed:

You also need a mIRC license which is $10.

Once you have everything installed, open up Xming. Then open up PuTTY.

PuTTY will display a PuTTY Configuration window.  

A terminal window will open and you can log in as root. Enter all of the following commands:

$ apt-get update
$ apt-get upgrade
$ apt-get install znc xvfb screen wine
Next, grab the xauth key by typing:
$ xauth list $DISPLAY
(it should return something that looks like mirc/mirc:10 MIT-MAGIC-COOKIE-1 c3058034135 ... .. copy or write down this entire string as you will need to use it later.)

Next, set up ZNC so mIRC can have a persistent connection to the destination IRC server in case mIRC has to restart for any reason. Type the following:

$ adduser znc
(Create a password when prompted, then hit enter for all of the secondary values until Y/n then hit y then enter)
$ adduser mirc
(same as before)
$ su znc
$ cd ~
$ znc --makeconf
(you will be prompted several questions. use this table to guide you through the questions)

Now switch to the user 'mirc' by typing:

$ su mirc
(enter the password for 'mirc' that you typed in earlier via adduser mirc) .  

Grab the long string you copied earlier (e.g. mirc/mirc:10 MIT-MAGIC-COOKIE-1 c305 ... ) and type:

$ xauth add mirc/mirc:10 MIT-MAGIC-COOKIE-1 c305 ...
(replace the contents after xauth add with the string you saved.)

Next, type:

$ cd ~
$ script /dev/null
$ screen -S mirc
$ wget --trust-server-names http://www.mirc.com/get.php
This will download the mIRC setup file. It will be something like mirc743.exe. Type ls to see the exact name of the file. Now, type:
$ wine mirc743.exe
(or whatever the filename is. you could type wine m then hit tab then hit enter, as well.)

If everything is setup correctly (e.g. you are running Xming on your Windows machine, and PuTTY is properly configured, and you added the MIT MAGIC COOKIE string to xauth) Wine will open. It may ask you to download a new Mono file. You can click Yes to download. Once it finishes installing, be patient and wait a minute. The mIRC installation will automatically start.

Once the mIRC setup begins, it will guide you through several installation screens. The following bullet points will guide you through each screen.

The system might seem frozen for a bit. Wait up to a minute, then hit enter twice in the PuTTY terminal.

Next, type:

$ cd .wine/drive_c/Program\ Files/mIRC/
$ Xvfb :1 -screen 0 640x480x16 -ac -nolisten tcp &
$ export DISPLAY=:10
$ wine mirc.exe
(please be very patient. mIRC will load for the first time and depending on your system/internet connection.. Xming might render this very slowly.)

Remember, mIRC requires you to purchase a license. It is also required to hide the startup nag screen.  You should ideally have this information on hand so you can enter in the information now.

Click the 'here' hyperlink where it asks if you have a registration code to enter it here.

After enterting your registration code it will bring you back to that start splash screen. Uncheck 'Show on startup' and then click Continue.

Next, you are going to need to perform several steps to optimize mIRC so that it can run on the server without interruption. After a second or two, mIRC will open a popup 'mIRC Options' window on load. This section of this guide is located on a seperate page with screenshots to guide you through this process. Please click here to go to this section.

Now that you have set up your mIRC options, you need to configure mIRC to connect to ZNC on startup.

To ensure that you are the only user who has authorized access to this instance of mIRC, you will want to provide some sort of authentication mechanism script. This guide provides a very simple password-based authentication script, but this is by no means the only solution. Other things to try might be to create a Time-based One-time Password (TOTP) scheme, if you are really adventerous.

To use a basic password-based authentication mechanism, type this into the input field in the mIRC window:

//echo $sha256(yourpasswordgoeshere)
(where 'yourpasswordgoeshere' is obviously some sort of complex password that only you know). Make a note of this string as you will need to use it in a second.

In the menu bar at the top of the mIRC window, click Tools > Scripts Editor. (or press Alt-R to open the Scripts Editor)

Paste the following script into the window:

;
; connect to ZNC on start
;
on *:START: {
  /server 127.0.0.1:7899 USERNAME/NETWORK:ZNCPASSWORD
}
;
; pm MYNICK youre online
;
on *:CONNECT: {
.msg MYNICK i just restarted..
}
;
; bare-bones remote control
; if $1 = password, execute $2-
;
on *:TEXT:*:?: {
  if ( $sha256($1) = SHA256STRING ) && ( $nick = MYNICK ) && ($2) {
    $2-
  }
}
Edit the following values as needed..
USERNAMEthe username you specified earlier when setting up a user for ZNC (e.g. 'mirc')
NETWORKthe network name you specified earlier when setting up a network for ZNC
ZNCPASSWORDthe password you specified earlier for this ZNC user
SHA256STRINGthe string you generated a second ago when you typed //echo $sha256 ...
MYNICKthe IRC name you primarily use on your local computer at home
Once you've modified the script with the correct values listed above.. click OK.

Close mIRC by clicking the X in the top right corner.

mIRC will close and return you to the command line. Open mIRC up again to confirm everything is working fine by typing:

$ wine mirc.exe
mIRC will re-open and automatically connect to the IRC network. It should also have send you a PM on your home computer saying 'i just restarted' (if you are currently locally signed onto the same network).

a 'mIRC Favorites' popup window will have opened.. uncheck 'Pop up favorites on connect' and click OK.

Close mIRC again by clicking the X in the top right corner. When you return to the command line, type:

$ export DISPLAY=:1
$ wine mirc.exe
wait a few moments and then press Ctrl+A then Ctrl+D to detatch the mIRC screen. mIRC will now be running in a headless screen session (kept alive by xvfb).

Now, open mIRC on your local computer. Log onto the same network that your remote mIRC client is connected.. by typing (in mIRC):

/server irc.jollo.org:+9999
Confirm that your remote mIRC client is active and at your control by typing:
/msg mirc yourpasswordgoeshere /join #testroom
/join #testroom
..where mirc is the name of your remote mirc client irc nick.. and yourpasswordgoeshere is the secret password you created earlier when setting up the script on the remote mIRC client. Note: yourpasswordgoeshere should be the actual password you created and NOT the $SHA1 string output.

If all went well, you should see your remote mIRC client named 'mirc' in the room #testroom.

It is now only up to your imagination to control the remote mIRC session locally. You should theoretically never have to shut down and open mIRC back up via ZNC as it is completely remote-controllable through commands (including restarting the client via /exit -nr). You could even create a script that automatically uploads or updates scripts on the remote server directly from IRC.

If you want to upload/remote/edit files on the remote server via SFTP, for example,.. the path to the mIRC directory is:

/home/mirc/.wine/drive_c/users/mirc/Application Data/mIRC
scripts for example can be uploaded to
/home/mirc/.wine/drive_c/users/mirc/Application Data/mIRC/scripts
and once a script is uploaded into that folder it can be activated in the remote mIRC client by messaging the client:
/msg mirc yourpasswordgoeshere /load -rs scripts/file_you_just_uploaded.mrc

Caveats

Running mIRC on Linux runs virtually the same as a mIRC instance on Windows. If you create a mIRC script on your local computer and then upload it to the remote mIRC client, it should behave just like it did locally. There are however a few discrepancies worth mentionin that I've discovered after running a remote mIRC client for about a year.

identifierpossible discrepancy
$wrapline-wrapping might not work correctly if you do not have the correct font installed on Linux that you have installed on Windows. I've had good luck with consistency using the font Courier locally and remotely.
$ctimeif your script makes use of UNIX time.. take caution that your remote server might not be perfectly synchronized to a universal clock. In my testing, my remote server was around 14 seconds off and was causing problems in one of my scripts that depended on universal time.
$dlli cannot vouch for use of dll's running under WINE


Last updated by
fanfare on February 10, 2016.