<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Half-Baked Bits&#187; tools</title>
	<atom:link href="http://halfbakedbits.com/category/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://halfbakedbits.com</link>
	<description>Small Ideas Factory</description>
	<lastBuildDate>Fri, 09 Jan 2009 12:43:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Some fun with NSIS</title>
		<link>http://halfbakedbits.com/2008/10/some-fun-with-nsis/</link>
		<comments>http://halfbakedbits.com/2008/10/some-fun-with-nsis/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 01:23:00 +0000</pubDate>
		<dc:creator>Nathan Bedford</dc:creator>
				<category><![CDATA[tools]]></category>
		<category><![CDATA[Audacity]]></category>
		<category><![CDATA[installation wizard]]></category>
		<category><![CDATA[NSIS]]></category>
		<category><![CDATA[registry]]></category>

		<guid isPermaLink="false">http://halfbakedbits.com/?p=190</guid>
		<description><![CDATA[I was all set to write a riveting article on the importance of application UI response times, but another great little project came up and I couldn&#8217;t resist. Basically, my friend come up to me at work today and asked if I knew of any way to record and save a song she had heard [...]]]></description>
			<content:encoded><![CDATA[<p>I was all set to write a riveting article on the importance of application UI response times, but another great little project came up and I couldn&#8217;t resist.</p>

<p>Basically, my friend come up to me at work today and asked if I <a href="http://www.nathanbedford.com/blog/?p=25">knew of any way to record and save</a> a song she had heard on the internet.  It should go without saying that the legalities of this should be investigated a bit before trying this yourself, but in this case, I felt comfortable that we were within the law.</p>

<p><a href="http://audacity.sourceforge.net/">Audacity</a> can do this sort of thing nicely, but the problem is, Audacity doesn&#8217;t ship with an MP3 encoder (due to legal reasons, I suspect).  I needed to find a simple way to copy lame_enc.dll to the user&#8217;s hard drive, and create a registry key in the right spot that points to that dll.  There are a lot of ways to do this: a little .NET application, a variety of scripting languages, etc.  But let&#8217;s think about this for a sec&#8230;really, what you&#8217;re doing is a lot like what an installer does.  InstallShield, Wise Installer, the installation wizard that comes with Visual Studio, <a href="http://wix.sourceforge.net/">WiX</a>&#8230;all these are great, albeit a bit expensive and/or confusing.  Did you know there are two great, free alternatives?  <a href="http://www.jrsoftware.org/isinfo.php">Inno Setup</a> and <a href="http://nsis.sourceforge.net/Main_Page">NSIS </a>are both quite robust, fully scriptable, free installation packages.  As an aside, I&#8217;d encourage you to not underestimate the significance of having your installer be totally scriptable&#8230;just being able to follow the version of your installer via a source control system is immensely helpful.  And if you&#8217;re stuck with Windows Installer, check out WiX&#8230;it&#8217;s great.</p>

<p>Out of the free options, I tend toward NSIS for several key reasons:</p>

<ol>
<li>Helpful support community</li>
<li>Used by Google</li>
<li>Very small install files (smallest of all installers)</li>
</ol>

<p>There are <a href="http://nsis.sourceforge.net/Category:Development_Environments">several IDEs </a>to help you create and maintain NSIS installers.  I choose <a href="http://nsis.sourceforge.net/HM_NIS_Edit">HM NIS Edit</a> simply because it was first one I saw years ago (before all the others were available).  It has a nice little wizard that can help you build a simple installer script very quickly.</p>

<p>I walked through the wizard and chose lame_enc.dll as the only file that this installer will install.  I decided to put it in Program Files, since I assume that most users know not to randomly delete files from there.  Plus, it sort of fits there <img src='http://halfbakedbits.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>

<p>Now, all, we need to do is add the registry key that tells Audacity where to find lame_enc.dll.  The NSIS documentation is very helpful, and I found the answer in no time:</p>

<p><code>WriteRegStr HKEY_CURRENT_USER "Software\Audacity\Audacity\MP3" "MP3LibPath" "$PROGRAMFILES\LAME MP3 Encoder\lame_enc.dll"</code></p>

<p>My NSIS script already had a block of code called &#8220;MainSection&#8221;.  That block contains the operations that happen when the installer runs.  I just added my new operation to the end of the main section, and added a corresponding DeleteRegKey operation in the Uninstall section, and voila!  The installer was done.  Well, done after I compiled it, of course.  Now, all I need to do is point my friend to the Audacity installer, and the LAME MP3 Dll installer I just wrote in 3 minutes, and she&#8217;ll be making her own mp3s like a pro.</p>

<p>Oh, and remember when I said that NSIS makes small installers?  Well, the dll we&#8217;re installing here is 296KB, and the installer?  It&#8217;s 219KB.  Isn&#8217;t that refreshing?
<a href="http://halfbakedbits.com/wp-content/uploads/2008/10/installer.png"><img src="http://halfbakedbits.com/wp-content/uploads/2008/10/installer.png" alt="" title="installer" width="500" height="388" class="alignnone size-full wp-image-194" /></a></p>

<p>I hope every developer has a chance to spend some quality time learning how modern installers work.  That knowledge comes in handy more times than you might think.  Check out NSIS and Inno Setup for starters&#8230;they&#8217;re so simple to use, I bet you&#8217;ll find yourself thinking of ways to use them before you know it.</p>

<p><strong>Helpful links for this article:</strong></p>

<ul>
<li><a href="http://www.nathanbedford.com/dev/hbb/installer.nsi">Installer source file</a></li>
<li><a href="http://www.nathanbedford.com/dev/hbb/lame_installer.exe">Installer compiled 
<li><a href="http://www.nathanbedford.com/blog/?p=25">Article on how to save audio from the internet</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://halfbakedbits.com/2008/10/some-fun-with-nsis/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
