<?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"
	>

<channel>
	<title>acatalept/blog</title>
	<atom:link href="http://acatalept.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://acatalept.com/blog</link>
	<description>random notes of toil and hardship at the hands of our new master, the computer.</description>
	<pubDate>Fri, 14 Nov 2008 05:55:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Dead Space (PC) tweaks</title>
		<link>http://acatalept.com/blog/2008/11/14/dead-space-pc-tweaks/</link>
		<comments>http://acatalept.com/blog/2008/11/14/dead-space-pc-tweaks/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 05:55:49 +0000</pubDate>
		<dc:creator>acat</dc:creator>
		
		<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://acatalept.com/blog/?p=23</guid>
		<description><![CDATA[Since I&#8217;ve found this game is frustrating many users (myself included) with its tendency to force your mouse to work like a console game controller, among other things, I did some digging to overcome some of the issues I was having.

Very sluggish mouse input: Disable v-sync in the game options.  You might still be [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;ve found this game is frustrating many users (myself included) with its tendency to force your mouse to work like a console game controller, among other things, I did some digging to overcome some of the issues I was having.</p>
<ul>
<li><strong>Very sluggish mouse input:</strong> Disable <a href="http://www.tweakguides.com/Graphics_9.html">v-sync</a> in the game options.  You might still be able to force v-sync in your video driver configuration (<a href="http://www.tweakguides.com/NVFORCE_6.html">see here for Nvidia driver</a>) to eliminate tearing.</li>
<li><strong>Mouse input too slow / &#8220;swimmy&#8221;:</strong> You can only increase the mouse sensitivity so far in the game options, but if that&#8217;s still not sensitive enough for you, try editing the setting manually in the config file.  Open the file called <code>config.txt</code> in this folder under Windows XP:
<pre>C:\Documents and Settings\&lt;YOUR USER NAME&gt;\Local Settings\Application Data\Electronic Arts\Dead Space</pre>
<p>or this folder under Vista:</p>
<pre>C:\Users\&lt;YOUR USER NAME&gt;\Local Settings\Application Data\Electronic Arts\Dead Space</pre>
<p>Look for a setting for <code>Control.MouseSensitivity</code> - this only goes up to 1.0 from the in-game options menu, but you can theoretically set it quite a bit higher.  I currently have it set to 2.0, which is a pretty decent improvement.  <strong>Note:</strong> setting this too high will make the mouse <em>much</em> too sensitive in the in-game menus, so turn it up slowly and experiment.</li>
<li><strong>Brightness too high even at lowest setting:</strong> this one can also be tweaked in the config file above.  The setting is called <code>Window.Gamma</code> - the in-game brightness adjustment only sets this as low as 0.0, but apparently it can go negative.  Currently I have it set to -0.5, and it looks much more creepy and atmospheric.</li>
</ul>
<p>Hopefully EA will patch the claustrophobic, controller-esque feeling of the mouse at some point in the future, but otherwise these settings make a huge improvement over the out-of-the-box experience.</p>
]]></content:encoded>
			<wfw:commentRss>http://acatalept.com/blog/2008/11/14/dead-space-pc-tweaks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Stable quicksort in Javascript</title>
		<link>http://acatalept.com/blog/2008/10/28/stable-quicksort-in-javascript/</link>
		<comments>http://acatalept.com/blog/2008/10/28/stable-quicksort-in-javascript/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 18:30:37 +0000</pubDate>
		<dc:creator>acat</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Web design &amp; hosting]]></category>

		<guid isPermaLink="false">http://acatalept.com/blog/?p=21</guid>
		<description><![CDATA[Firefox < v3.0 doesn't have a stable Array.sort() function - that is, it doesn't maintain indexes for elements of equal value.  This is undefined in the ECMA spec, and has been fixed in Firefox as of version 3 (and curiously enough has been stable in IE all along).  As a result, I set [...]]]></description>
			<content:encoded><![CDATA[<p>Firefox < v3.0 doesn't have a stable Array.sort() function - that is, it doesn't maintain indexes for elements of equal value.  This is undefined in the ECMA spec, and has been fixed in Firefox as of version 3 (and curiously enough has been stable in IE all along).  As a result, I set out to find a stable, efficient Array.sort() replacement/supplement.<br />
<span id="more-21"></span><br />
<a href="http://en.wikipedia.org/wiki/Mergesort">Mergesort</a> is famous for being stable by design, and fast, though not terribly memory efficient.  However, it uses a lot of code, and I couldn&#8217;t manage to find a stable implementation of it.</p>
<p>After doing a little homework, I decided to modify <a href="http://en.wikipedia.org/wiki/Quicksort#Algorithm">this quicksort pseudocode</a> to get the results I was after.  Some would argue that <a href="http://stackoverflow.com/questions/70402/why-is-quicksort-better-than-mergesort">quicksort&#8217;s worst case performance is slower than mergesort</a>, but for my purposes (small datasets) this was moot.</p>
<p>Here is the resulting code:</p>
<pre>
// STABLE implementation of quick sort to replace unstable Array.sort method in Firefox
quickSort = function(arr) {

  // return if array is unsortable
  if (arr.length <= 1){
    return arr;
  }

  var less = Array(), greater = Array();

  // select and remove a pivot value pivot from array
  // a pivot value closer to median of the dataset may result in better performance
  var pivotIndex = Math.floor(arr.length / 2);
  var pivot = arr.splice(pivotIndex, 1)[0];

  // step through all array elements
  for (var x = 0; x < arr.length; x++){

    // if (current value is less than pivot),
    // OR if (current value is the same as pivot AND this index is less than the index of the pivot in the original array)
    // then push onto end of less array
    if (
      (arr[x] < pivot)
      ||
      (arr[x] == pivot &#038;&#038; x < pivotIndex)  // this maintains the original order of values equal to the pivot
    ){
      less.push(arr[x]);
    }

    // if (current value is greater than pivot),
    // OR if (current value is the same as pivot AND this index is greater than or equal to the index of the pivot in the original array)
    // then push onto end of greater array
    else {
      greater.push(arr[x]);
    }
  }

  // concatenate less+pivot+greater arrays
  return quickSort(less).concat([pivot], quickSort(greater));
};
</pre>
<p>Of course, this will only sort an array of values (strings, numbers), so to sort an array of objects by a given property, I modified the above to produce:</p>
<pre>
// STABLE implementation of quick sort to replace unstable Array.sort method in Firefox
// if sorting an array of objects, key = name of object property to compare
// otherwise leave key undefined
quickSort = function(arr, key) {

  // return if array is unsortable
  if (arr.length <= 1){
    return arr;
  }

  var less = Array(), greater = Array();

  // select and remove a pivot value pivot from array
  // a pivot value closer to median of the dataset may result in better performance
  var pivotIndex = Math.floor(arr.length / 2);
  var pivot = arr.splice(pivotIndex, 1)[0];

  // step through all array elements
  for (var x = 0; x < arr.length; x++){

    // if (current value is less than pivot),
    // OR if (current value is the same as pivot AND this index is less than the index of the pivot in the original array)
    // then push onto end of less array
    if (
      (
        !key  // no object property name passed
        &#038;&#038;
        (
          (arr[x] < pivot)
          ||
          (arr[x] == pivot &#038;&#038; x < pivotIndex)  // this maintains the original order of values equal to the pivot
        )
      )
      ||
      (
        key  // object property name passed
        &#038;&#038;
        (
          (arr[x][key] < pivot[key])
          ||
          (arr[x][key] == pivot[key] &#038;&#038; x < pivotIndex)  // this maintains the original order of values equal to the pivot
        )
      )
    ){
      less.push(arr[x]);
    }

    // if (current value is greater than pivot),
    // OR if (current value is the same as pivot AND this index is greater than or equal to the index of the pivot in the original array)
    // then push onto end of greater array
    else {
      greater.push(arr[x]);
    }
  }

  // concatenate less+pivot+greater arrays
  return quickSort(less, key).concat([pivot], quickSort(greater, key));
};
</pre>
<h1>Code samples</h1>
<p>Now we can define an array of objects such as:</p>
<pre>
var objects = [
  {id: 1, type: 'fruit', name: 'apple', color: 'yellow'},
  {id: 2, type: 'vegetable', name: 'tomato', color: 'red'},
  {id: 3, type: 'fruit', name: 'apple', color: 'red'},
  {id: 4, type: 'vegetable', name: 'pepper', color: 'red'}
];
</pre>
<p>Then sort by color with a call to:</p>
<pre>
objects = quickSort(objects, 'color');

// sorted
objects = [
  {id: 2, type: 'vegetable', name: 'tomato', color: 'red'},
  {id: 3, type: 'fruit', name: 'apple', color: 'red'},
  {id: 4, type: 'vegetable', name: 'pepper', color: 'red'},
  {id: 1, type: 'fruit', name: 'apple', color: 'yellow'}
];
</pre>
<p>Then sort by type:</p>
<pre>
objects = quickSort(objects, 'type');

// sorted
objects = [
  {id: 3, type: 'fruit', name: 'apple', color: 'red'},
  {id: 1, type: 'fruit', name: 'apple', color: 'yellow'},
  {id: 2, type: 'vegetable', name: 'tomato', color: 'red'},
  {id: 4, type: 'vegetable', name: 'pepper', color: 'red'}
];
</pre>
<p>Then sort by name:</p>
<pre>
objects = quickSort(objects, 'name');

// sorted
objects = [
  {id: 3, type: 'fruit', name: 'apple', color: 'red'},
  {id: 1, type: 'fruit', name: 'apple', color: 'yellow'},
  {id: 4, type: 'vegetable', name: 'pepper', color: 'red'},
  {id: 2, type: 'vegetable', name: 'tomato', color: 'red'}
];
</pre>
]]></content:encoded>
			<wfw:commentRss>http://acatalept.com/blog/2008/10/28/stable-quicksort-in-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MySQL inner join to perform update from same table</title>
		<link>http://acatalept.com/blog/2008/09/09/mysql-inner-join-to-perform-update-from-same-table/</link>
		<comments>http://acatalept.com/blog/2008/09/09/mysql-inner-join-to-perform-update-from-same-table/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 19:15:13 +0000</pubDate>
		<dc:creator>acat</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Web design &amp; hosting]]></category>

		<guid isPermaLink="false">http://acatalept.com/blog/?p=20</guid>
		<description><![CDATA[Typically, using SELECT in a subquery to perform an UPDATE on the same table, such as:

UPDATE table1 AS target
SET field1 = (
    SELECT field2
    FROM table1 AS source
    WHERE source.id = target.id
)

is illegal in MySQL.  To achieve the desired effect, you can perform an INNER [...]]]></description>
			<content:encoded><![CDATA[<p>Typically, using SELECT in a subquery to perform an UPDATE on the same table, such as:</p>
<pre>
UPDATE table1 AS target
SET field1 = (
    SELECT field2
    FROM table1 AS source
    WHERE source.id = target.id
)
</pre>
<p>is illegal in MySQL.  To achieve the desired effect, you can perform an INNER JOIN in the UPDATE:</p>
<pre>
UPDATE table1 AS target
INNER JOIN table1 AS source USING(id)
SET target.field1 = source.field2
</pre>
]]></content:encoded>
			<wfw:commentRss>http://acatalept.com/blog/2008/09/09/mysql-inner-join-to-perform-update-from-same-table/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Apache cache control for dynamic or secure content</title>
		<link>http://acatalept.com/blog/2008/06/10/apache-cache-control-for-dynamic-or-secure-content/</link>
		<comments>http://acatalept.com/blog/2008/06/10/apache-cache-control-for-dynamic-or-secure-content/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 14:28:14 +0000</pubDate>
		<dc:creator>acat</dc:creator>
		
		<category><![CDATA[Web design &amp; hosting]]></category>

		<guid isPermaLink="false">http://acatalept.com/blog/?p=19</guid>
		<description><![CDATA[Cache control is a potentially hit-and-miss pursuit, but the most reliable and straightforward method I&#8217;ve found (that works for IE 6+ and Firefox), although it relies on access to your Apache server configuration, is simply setting Cache-Control headers manually.

For example, to prevent web browsers (or any intermediary such as a proxy) from caching dynamically generated [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mnot.net/cache_docs/">Cache control</a> is a potentially hit-and-miss pursuit, but the most reliable and straightforward method I&#8217;ve found (that works for IE 6+ and Firefox), although it relies on access to your Apache server configuration, is simply setting <strong>Cache-Control</strong> headers manually.<br />
<span id="more-19"></span><br />
For example, to prevent web browsers (or any intermediary such as a proxy) from caching dynamically generated content, such as from a PHP script, do the following: In <strong>httpd.conf</strong>, under your DocumentRoot configuration, add something like this:</p>
<pre><code lang="xhtml">DocumentRoot "g:/server/HTML/acatalept.com/root"
<Directory />
    <FilesMatch "\.(php)$">
        Header Set Cache-Control "max-age=0, no-store"
    </FilesMatch>
</Directory></code></pre>
<p>The <strong>FilesMatch</strong> will apply only to the regex string specified (in this case, any PHP file).  More importantly, the <strong>Header Set</strong> instruction sets a Cache-Control header with the value in quotes, resulting in the following response header being sent to the cilent:</p>
<pre><code markup="all">Cache-Control: max-age=0, no-store</code></pre>
<p>The <strong>max-age</strong> value causes content to expire immediately, and <strong>no-store</strong> causes content to never be stored (cached) under any conditions.  Note that this is different in practice than the <strong>no-cache</strong> directive, which is slightly more lenient and designed to help enforce a working authentication mechanism.  See <a href="http://www.mnot.net/cache_docs/">the link at the top of this post</a> for more details.</p>
]]></content:encoded>
			<wfw:commentRss>http://acatalept.com/blog/2008/06/10/apache-cache-control-for-dynamic-or-secure-content/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Make Vista Explorer view settings work like XP Explorer</title>
		<link>http://acatalept.com/blog/2008/04/25/make-vista-explorer-view-settings-work-like-xp-explorer/</link>
		<comments>http://acatalept.com/blog/2008/04/25/make-vista-explorer-view-settings-work-like-xp-explorer/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 13:33:03 +0000</pubDate>
		<dc:creator>acat</dc:creator>
		
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://acatalept.com/blog/?p=18</guid>
		<description><![CDATA[(Lifted from http://www.vistax64.com/tutorials/70819-windows-explorer-folder-view-settings.html)
Vista Explorer, by default, tries to determine what type of folder you&#8217;re viewing based on its contents, and may dramatically (and seemingly unpredictably) change the folder&#8217;s view settings: Details view, or List view, or Thumbnails view, etc., as well as applying Grouping, adding or removing visible columns, and so on.  To disable [...]]]></description>
			<content:encoded><![CDATA[<p>(Lifted from <a href="http://www.vistax64.com/tutorials/70819-windows-explorer-folder-view-settings.html">http://www.vistax64.com/tutorials/70819-windows-explorer-folder-view-settings.html</a>)</p>
<p>Vista Explorer, by default, tries to determine what type of folder you&#8217;re viewing based on its contents, and may dramatically (and seemingly unpredictably) change the folder&#8217;s view settings: Details view, or List view, or Thumbnails view, etc., as well as applying Grouping, adding or removing visible columns, and so on.  To disable this behavior, and have all folders work more like XP Explorer, do the following:</p>
<ol>
<li><strong>Delete existing folder type customizations in the registry:</strong> Open regedit.exe, and navigate to:
<pre>HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell</pre>
<p>Delete the keys <strong>Bags</strong> and <strong>BagsMRU</strong>.</li>
<li><strong>Add new registry setting to enable common behavior:</strong> Still in Registry Editor, under the same Shell key (above), create a series of new keys: <strong>Bags</strong>, then within that <strong>AllFolders</strong>, then within that another <strong>Shell</strong>, to end up with this:
<pre>HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell</pre>
<p>Inside the last Shell key, create a new string value named <strong>FolderType</strong>, with a value of <strong>NotSpecified</strong>.</p>
<p>Reboot or logoff and back on again to make these changes take effect.</li>
<li><strong>Make changes to Vista Explorer&#8217;s view settings:</strong> In Explorer, open the Tools menu (if you don&#8217;t see the menus, hit the Alt key to temporarily display them, or click Organize->Layout and put a check next to Menu Bar), and click Folder options.  Set these as you like them, paying special attention to the option <strong>Remember each folder&#8217;s view settings</strong> - if this is unchecked, and you click the <strong>Apply to Folders</strong> button at the top of the window, all folders will behave exactly the same.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://acatalept.com/blog/2008/04/25/make-vista-explorer-view-settings-work-like-xp-explorer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to download Internet Explorer 6 standalone installer</title>
		<link>http://acatalept.com/blog/2008/02/12/how-to-download-internet-explorer-6-standalone-installer/</link>
		<comments>http://acatalept.com/blog/2008/02/12/how-to-download-internet-explorer-6-standalone-installer/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 20:35:05 +0000</pubDate>
		<dc:creator>acat</dc:creator>
		
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.acatalept.com/blog/2008/02/12/how-to-download-internet-explorer-6-standalone-installer/</guid>
		<description><![CDATA[When you need to update Internet Explorer on a computer without internet access (yes, it can happen):
http://support.microsoft.com/?kbid=257249
You have to jump through hoops, but it works.  Just be careful with the syntax (there really are 3 quotes at the end of the command - good ol&#8217; MS engineering ;).
NOTE: You will be asked a few [...]]]></description>
			<content:encoded><![CDATA[<p>When you need to update Internet Explorer on a computer without internet access (yes, it can happen):</p>
<p><a href="http://support.microsoft.com/?kbid=257249" target="_blank">http://support.microsoft.com/?kbid=257249</a></p>
<p>You have to jump through hoops, but it works.  Just be careful with the syntax (there really are 3 quotes at the end of the command - good ol&#8217; MS engineering ;).</p>
<p><strong>NOTE:</strong> You will be asked a few times throughout this initial download process, &#8220;Are you sure you want to install/run this software?&#8221;  Don&#8217;t be alarmed, the installer won&#8217;t actually run at this point, it will simply continue downloading more components.  When it completes, it will explicitly tell you that the components have completed downloading, and to run <code>ie6setup.exe</code> in the download folder you specified to begin installation.</p>
]]></content:encoded>
			<wfw:commentRss>http://acatalept.com/blog/2008/02/12/how-to-download-internet-explorer-6-standalone-installer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HTML DOCTYPE can be your friend - or your enemy&#8230;</title>
		<link>http://acatalept.com/blog/2008/02/03/html-doctype-can-be-your-friend-or-your-enemy/</link>
		<comments>http://acatalept.com/blog/2008/02/03/html-doctype-can-be-your-friend-or-your-enemy/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 06:41:05 +0000</pubDate>
		<dc:creator>acat</dc:creator>
		
		<category><![CDATA[Web design &amp; hosting]]></category>

		<guid isPermaLink="false">http://www.acatalept.com/blog/2008/02/03/html-doctype-can-be-your-friend-or-your-enemy/</guid>
		<description><![CDATA[When you just need to get the job done, sometimes it pays to visit the wayback machine.  Recent DOCTYPEs can wreak havoc on even simple layouts when relying on deprecated functionality.
For instance, even HTML 4.01 Transitional:
&#60;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"&#62;
doesn&#8217;t support the good old table HEIGHT property - you will get mixed [...]]]></description>
			<content:encoded><![CDATA[<p>When you just need to get the job done, sometimes it pays to visit the wayback machine.  Recent DOCTYPEs can wreak havoc on even simple layouts when relying on deprecated functionality.</p>
<p><span id="more-16"></span>For instance, even HTML 4.01 Transitional:</p>
<pre>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"&gt;</pre>
<p>doesn&#8217;t support the good old table HEIGHT property - you will get mixed results when setting absolute heights on TABLEs or TDs.  However, rolling back to HTML 3.2 Final:</p>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"&gt;</pre>
<p>will magically restore this functionality.  Go ahead, make a 3 row table that fills 100% of the window, with the middle row set to a fixed height and the outer rows filling the remaining height:</p>
<pre>&lt;table style="height: 100%" border="1"&gt;&lt;tbody&gt;
    &lt;tr&gt;
        &lt;td&gt;Row 1 fills top half of table&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr style="height: 100px"&gt;
        &lt;td&gt;Row 2 is exactly 100 pixels high&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Row 3 fills bottom half of table&lt;/td&gt;
    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</pre>
<p>This will work under Firefox using both HTML 4.01 and 3.2, but only 3.2 will produce the desired effect in Internet Explorer.</p>
<p>Sad that it&#8217;s still so difficult to achieve some seemingly basic results with the latest standards.  Further reading at <a href="http://www.w3.org/QA/Tips/Doctype" title="World Wide Web Consortium" target="_blank">W3C</a> and <a href="http://htmlhelp.com/tools/validator/doctype.html">HTMLHelp</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://acatalept.com/blog/2008/02/03/html-doctype-can-be-your-friend-or-your-enemy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Map network drives at login</title>
		<link>http://acatalept.com/blog/2007/12/27/map-network-drives-at-login/</link>
		<comments>http://acatalept.com/blog/2007/12/27/map-network-drives-at-login/#comments</comments>
		<pubDate>Thu, 27 Dec 2007 21:32:50 +0000</pubDate>
		<dc:creator>acat</dc:creator>
		
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.acatalept.com/blog/2007/12/27/map-network-drives-at-login/</guid>
		<description><![CDATA[(Win2k, XP, Vista) Using NET USE in a batch file at login to force-connect mapped drives&#8230; useful for situations where mapped drives mysteriously disappear (this script can safely be re-run repeatedly) or to prevent conflicts between network shares requiring conflicting credentials.

First, copy and paste the following into a new text file, and save it somewhere [...]]]></description>
			<content:encoded><![CDATA[<p>(Win2k, XP, Vista) Using NET USE in a batch file at login to force-connect mapped drives&#8230; useful for situations where mapped drives mysteriously disappear (this script can safely be re-run repeatedly) or to prevent conflicts between network shares requiring conflicting credentials.<br />
<span id="more-15"></span><br />
First, copy and paste the following into a new text file, and save it somewhere convenient as MapNetworkDrives.bat:</p>
<pre>@echo off
rem Windows 2k/XP/Vista batch file

rem Designed to be run at logon, after scheduled interval, or on demand, to map
rem network drives with specific permissions

rem -- SYNTAX

rem Pause for timed interval:
rem ping 127.0.0.1 -n NUMBEROFPINGS -w PINGTIMEOUT &gt; nul

rem Remove existing share:
rem net use DRIVELETTER: /delete /y

rem Add new share:
rem net use DRIVELETTER: \\SERVER\SHARENAME
rem        [/user:SERVER\USERNAME PASSWORD] [/persistent:YES|NO]

TITLE Connecting network drives...
echo.
echo ____________________________________________
echo.
echo   Connecting network drives manually
echo ____________________________________________
echo.
echo.

rem Wait 5 seconds to allow network to become available
rem in case this was run at login.
rem If this script is never run at login, this section can be
rem commented out or removed.
echo - Waiting 5 seconds for network...
ping 127.0.0.1 -n 2 -w 1000 &gt; nul
ping 127.0.0.1 -n 5 -w 1000 &gt; nul
echo Now it should be safe to try connecting.
echo.
echo.

rem First disconnect existing maps to ensure permissions don't clash
echo - Removing any existing mapped drives...
if exist p: net use p: /delete /y
if exist q: net use q: /delete /y
if exist r: net use r: /delete /y
echo.
echo.

rem Then connect shares with full permissions
echo - Connecting new mapped drives...
net use p: \\server\share1 /user:"server\priviledged" secret /persistent:no
net use q: \\server\share2 /user:"server\priviledged" secret /persistent:no
net use r: \\server\share3 /user:"server\priviledged" secret /persistent:no
echo.
echo.

TITLE Finished
echo ____________________________________________
echo.

rem Wait another 5 seconds
echo This window will close in 5 seconds...
ping 127.0.0.1 -n 2 -w 1000 &gt; nul
ping 127.0.0.1 -n 5 -w 1000 &gt; nul</pre>
<p>Of course, replace &#8220;server&#8221; with your server name, &#8220;share#&#8221; with your share name, &#8220;privileged&#8221; with a username on the server with appropriate access privileges for the share, and &#8220;secret&#8221; with the password for the above username.</p>
<p>Simply create a shortcut to this batch file in the Start Menu under the Startup folder, right-click Properties and set Run as Minimized, and it should stay out of the way while safely doing its thing.</p>
<p>Note that this script doesn&#8217;t always work successfully if there is an open network share using different credentials than those supplied&#8230; NET USE /DELETE seems to throw an error in this case rather than forcing the connection to close.  Just manually disconnect any remaining shares to prevent them from reconnecting automatically at the next login, reboot, and run the script then.</p>
]]></content:encoded>
			<wfw:commentRss>http://acatalept.com/blog/2007/12/27/map-network-drives-at-login/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mirror folder structure (flat, single tree level only)</title>
		<link>http://acatalept.com/blog/2007/12/27/mirror-folder-structure-flat-no-recursion/</link>
		<comments>http://acatalept.com/blog/2007/12/27/mirror-folder-structure-flat-no-recursion/#comments</comments>
		<pubDate>Thu, 27 Dec 2007 19:47:10 +0000</pubDate>
		<dc:creator>acat</dc:creator>
		
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.acatalept.com/blog/2007/12/27/mirror-folder-structure-flat-no-recursion/</guid>
		<description><![CDATA[(Requires Win2k, XP, or Vista) Using FOR at the command line to step through every subfolder in a given folder, and create new folders with those names in a different parent folder.
Suppose you have a group of folders under C:\test1, like this:
C:\
&#124;
+-test1
  &#124;
  +-folder1
  &#124;
  +-folder2
  &#124;
  +-folder3
And you [...]]]></description>
			<content:encoded><![CDATA[<p>(Requires Win2k, XP, or Vista) Using FOR at the command line to step through every subfolder in a given folder, and create new folders with those names in a different parent folder.</p>
<p>Suppose you have a group of folders under C:\test1, like this:</p>
<pre>C:\
|
+-test1
  |
  +-folder1
  |
  +-folder2
  |
  +-folder3</pre>
<p>And you want to create a new test2 folder under C:\, which will contain emtpy folders with the same names as those in test1, like this:<br />
<span id="more-14"></span></p>
<pre>C:\
|
+-test2
  |
  +-folder1
  |
  +-folder2
  |
  +-folder3</pre>
<p>Navigate to your target folder (in this case, C:\test2), and enter the following command:</p>
<pre>for /d %a in ("..\test1\*") do md "%~na"</pre>
<p>The /d tells it to only look at folder names, and the %a is the placeholder variable for each found item.  Note that the second reference to %a has a ~n inserted to tell it to only reference the name of the found item - otherwise the entire path will be used, and it will attempt to create new folders on top of the existing ones in the source location.<br />
Note that you can also clear out any existing folders in the source that are empty (if those are no longer needed in the new mirror) by using the following command from the source folder:</p>
<pre>for /d %a in (*) do rd /q "%a"</pre>
<p>Note also that you must use double percents (%%) if you include those commands in a batch file, to differentiate from batch file variables.</p>
]]></content:encoded>
			<wfw:commentRss>http://acatalept.com/blog/2007/12/27/mirror-folder-structure-flat-no-recursion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Replacing Windows protected system files (XP/Vista)</title>
		<link>http://acatalept.com/blog/2007/12/19/replacing-windows-protected-system-files-xpvista/</link>
		<comments>http://acatalept.com/blog/2007/12/19/replacing-windows-protected-system-files-xpvista/#comments</comments>
		<pubDate>Wed, 19 Dec 2007 21:34:33 +0000</pubDate>
		<dc:creator>acat</dc:creator>
		
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.acatalept.com/blog/2007/12/19/replacing-windows-protected-system-files-xpvista/</guid>
		<description><![CDATA[Windows tries very hard to prevent you from replacing or deleting critical system files, even something as mundane as notepad.exe.
Note that this behavior is designed to keep your system functional whenever a critical file is accidentally (or maliciously) deleted or modified, and any actions you take to modify your system at this level, even with [...]]]></description>
			<content:encoded><![CDATA[<p>Windows tries very hard to prevent you from replacing or deleting critical system files, even something as mundane as <strong>notepad.exe</strong>.</p>
<p><span class="fontred">Note that this behavior is designed to keep your system functional whenever a critical file is accidentally (or maliciously) deleted or modified, and any actions you take to modify your system at this level, even with the best of intentions and what may seem like reliable information, may very well cause unexpected results to occur, such as an unstable or unbootable computer, or even lost data.  <strong>BACK UP YOUR DATA REGULARLY</strong>, especially before attempting modifications to your operating system files, and make sure you have a backup of your operating system to fall back on in case something goes wrong.</span></p>
<p>Suffice to say, there is a relatively simple way to bypass Windows file protection.  In fact, there are two very different methods for XP and Vista due to the way they protect operating system files:</p>
<p><span id="more-13"></span><strong><u></u></strong></p>
<h2><strong><u>The XP Method</u></strong></h2>
<p>(scroll down for the Vista Method)<strong><br />
</strong></p>
<blockquote><p><strong>1</strong>. First off, copy and paste the following code into a new text file, and save it as wsfr-xp.bat in an easy-to-find location (such as C:\ for this example for the sake of clarity):</p>
<pre>
@echo off

rem Windows XP batch file

rem Safely replaces a Windows protected operating system file.

rem 1. Deletes any references in the Prefetch folder
rem 2. Renames existing files with "-YEAR-MONTH-DAY-HHMMSS.backup"
rem    appended to the end of the filename (in case you need to restore
rem    the original file)
rem 3. Copies source file to target destination, effectively replacing
rem    original file

rem Must be run from command prompt drag and drop target file onto
rem this file in Explorer throws an error due to full path being
rem embedded in parameter

rem Target file MUST BE IN SAME FOLDER AS SCRIPT
rem Pointing to a different folder will throw as error

rem USAGE (at command prompt)

rem wsfr-xp FILENAME

for /f "delims=/ tokens=1-3" %%a in ("%DATE:~4%") do (
  for /f "delims=:. tokens=1-4" %%m in ("%TIME: =0%") do (
    set BACKUPTAG=%%c-%%b-%%a-%%m%%n%%o%%p
  )
)

echo Removing windows\prefetch file...
if exist "c:\windows\prefetch\%1*.*" del "c:\windows\prefetch\%1*.*"
echo __________
echo.

echo Replacing windows\servicepackfiles\i386 file...
if exist "c:\windows\servicepackfiles\i386\%1" (
  ren "c:\windows\servicepackfiles\i386\%1" "%1-%BACKUPTAG%.backup"
  copy /y "%1" "c:\windows\servicepackfiles\i386\%1"
)
echo __________
echo.

echo Replacing windows\system32\dllcache file...
if exist "c:\windows\system32\dllcache\%1" (
  ren "c:\windows\system32\dllcache\%1" "%1-%BACKUPTAG%.backup"
  copy /y "%1" "c:\windows\system32\dllcache\%1"
)
echo __________
echo.

echo Replacing windows\system32 file...
if exist "c:\windows\system32\%1" (
  ren "c:\windows\system32\%1" "%1-%BACKUPTAG%.backup"
  copy /y "%1" "c:\windows\system32\%1"
)
echo __________
echo.

echo Replacing windows file...
if exist "c:\windows\%1" (
  ren "c:\windows\%1" "%1-%BACKUPTAG%.backup"
  copy /y "%1" "c:\windows\%1"
)
echo.

pause</pre>
<p><strong>2</strong>. Copy your <strong>source</strong> file (the new file you will use to replace the original protected Windows file) into the same location as the batch file above (C:\ in this example).  Make sure that your source file has exactly the same file name as your target file (the original, protected file).  <strong>NOTE: </strong>This method <em>will not work</em> if your source file and batch file are in different folders, due to the way the parameters are passed at the command line (sure, there&#8217;s gotta be a better way, but I just haven&#8217;t dug <em>that</em> deep).</p>
<p><strong>3</strong>. Open a command prompt wherever your files from the previous steps are located (C:\ in this example).</p>
<p><strong>4</strong>. At the command prompt, enter the following and press Enter:</p>
<pre>wsfr-xp notepad.exe</pre>
<p>Substituting the name of your file in place of &#8220;notepad.exe&#8221; as seen above.</p></blockquote>
<h2><strong><u>The Vista Method</u></strong></h2>
<blockquote><p><strong>1</strong>. First off, copy and paste the following code into a new text file, and save it as wsfr-xp.bat in an easy-to-find location (such as C:\ for this example for the sake of clarity):</p>
<pre>
@echo off

rem Windows Vista batch file

rem Safely replaces a Windows protected operating system file.

rem 1. Deletes any references in the Prefetch folder
rem 2. Takes ownership of existing target file(s)
rem 3. Renames existing files with "-YEAR-MONTH-DAY-HHMMSS.backup"
rem    appended to the end of the filename (in case you need to restore
rem    the original file)
rem 4. Copies source file to target destination, effectively replacing
rem    original file

rem Must be run from command prompt AS ADMINISTRATOR (right-click,
rem run as Administrator); drag and drop target file onto this file
rem in Explorer throws an error due to full path being embedded in
rem parameter

rem Target file MUST BE IN SAME FOLDER AS SCRIPT
rem Pointing to a different folder will throw as error

rem USAGE (at command prompt)

rem wsfr-vista USERNAME FILENAME

for /f "delims=/ tokens=1-3" %%a in ("%DATE:~4%") do (
  for /f "delims=:. tokens=1-4" %%m in ("%TIME: =0%") do (
    set BACKUPTAG=%%c-%%b-%%a-%%m%%n%%o%%p
  )
)

echo Removing windows\prefetch file...
if exist "c:\windows\prefetch\%2*.*" (
  takeown /f "c:\windows\prefetch\%2*.*"
  icacls "c:\windows\prefetch\%2*.*" /grant %1:f
  del "c:\windows\prefetch\%2*.*"
)
echo __________
echo.

echo Replacing windows\system32 file...
if exist "c:\windows\system32\%2" (
  takeown /f "c:\windows\system32\%2"
  icacls "c:\windows\system32\%2" /grant %1:f
  ren "c:\windows\system32\%2" "%2-%BACKUPTAG%.backup"
  copy /y "%2" "c:\windows\system32"
)
echo __________
echo.

echo Replacing windows file...
if exist "c:\windows\%2" (
  takeown /f "c:\windows\%2"
  icacls "c:\windows\%2" /grant %1:f
  ren "c:\windows\%2" "%2-%BACKUPTAG%.backup"
  copy /y "%2" "c:\windows"
)
echo __________
echo.

pause</pre>
<p><strong>2</strong>. Copy your <strong>source</strong> file (the new file you will use to replace the original protected Windows file) into the same location as the batch file above (C:\ in this example). Make sure that your source file has exactly the same file name as your target file (the original, protected file). <strong>NOTE: </strong>This method <em>will not work</em> if your source file and batch file are in different folders, due to the way the parameters are passed at the command line (sure, there&#8217;s gotta be a better way, but I just haven&#8217;t dug <em>that</em> deep).</p>
<p><strong>3</strong>. Open a command prompt wherever your files from the previous steps are located (C:\ in this example).</p>
<p><strong>4</strong>. At the command prompt, enter the following and press Enter:</p>
<pre>wsfr-vista username notepad.exe</pre>
<p>Substituting your Windows user name for &#8220;username&#8221; and the name of your file in place of &#8220;notepad.exe&#8221; in the example above.</p></blockquote>
<p>Be aware that the batch files for XP and Vista are quite different, in that Vista requires you to take ownership of a protected file and grant yourself permissions before you can do much of anything with it.</p>
<h2><u><strong>If you run into trouble, try the following:</strong></u></h2>
<p><strong>- If all else fails, remember that you can always go back to your original file:</strong> every time you run these scripts, they will first save your original target file as a time-stamped backup in the same location, with a filename such as &#8220;notepad.exe-2007-12-19-123456.backup&#8221; - essentially the original filename plus a unique marker to indicate the date and time that the file was backed up.</p>
<p>- If you get an error message about Windows File Protection, and your replacement file doesn&#8217;t &#8220;stick&#8221; (it is itself replaced by the original file within a few moments), then search your system for a copy of the original file that isn&#8217;t referenced by the script above.  Sometimes a new computer that came with Windows preinstalled may store backups of operating system files in a special folder or partition, which Windows will be able to recover its original files from when you try to overwrite them.  If you find the original file located elsewhere, add an appropriate entry to the relevant script above to include it in the backup/overwrite process.</p>
]]></content:encoded>
			<wfw:commentRss>http://acatalept.com/blog/2007/12/19/replacing-windows-protected-system-files-xpvista/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
