A number of us indulge in a little mayhem during lunchtime at work in the form of running around with guns shooting each other. Or at least, we play Raven Shield. To avoid network issues we “turn off” DNS and have to remember to turn it back on after we have beaten each other to a pulp, or worse. If we don’t PerlMonks doesn’t work any more :(

A workmate wrote the code below and I added to it slightly. It changes the DNS server address to the local machine, launches Raven Shield, then restores the DNS server when Raven Shield exits. Enjoy.

use strict; use warnings; # change these to work with your machine. my $interface_name = "Local Area Connection"; my $RSPath = 'C:\games~~\Red Storm Entertainment\RavenShield'; # Get current IP my $config = `ipconfig`; $config =~ /IP Address[. :]+([\d.]*)/; my $myIP = $1; munt(); show(); launch(); unmunt(); show(); sub launch { print `$RSPath/system/RavenShield.exe`; } sub munt { print `netsh interface ip set dns "$interface_name" static $myIP`; } sub unmunt { print `netsh interface ip set dns "$interface_name" dhcp`; } sub show { print `netsh interface ip show dns`; }

DWIM is Perl's answer to Gödel

In reply to Stealth Raven Shield launcher - Switching DNS server under Win32 by GrandFather

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.