<?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>Elegant Code &#187; Windows</title>
	<atom:link href="http://elegantcode.com/tag/windows/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Sun, 12 Feb 2012 04:40:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Add Vista Themes to Longhorn</title>
		<link>http://elegantcode.com/2008/04/08/add-vista-themes-to-longhorn/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=add-vista-themes-to-longhorn</link>
		<comments>http://elegantcode.com/2008/04/08/add-vista-themes-to-longhorn/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 15:29:07 +0000</pubDate>
		<dc:creator>Alex Mueller</dc:creator>
				<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2008/04/08/add-vista-themes-to-longhorn/</guid>
		<description><![CDATA[It is nice to be able to apply the Vista themes and sidebar personalizations (eye candy) to a Longhorn environment. This site appears to be thorough on the topic of Converting your Windows 2008 Server to a Workstation. This article got me started with enabling the &#8220;aero&#8221; theme, Windows Server 2008 &#8220;Aero Enabled&#8221; Workstation Edition.]]></description>
			<content:encoded><![CDATA[<p>It is nice to be able to apply the Vista themes and sidebar personalizations (eye candy) to a Longhorn environment. This site appears to be thorough on the topic of <a target="_blank" href="http://www.win2008workstation.com/wordpress/" title="Converting your Windows 2008 Server to a Workstation">Converting your Windows 2008 Server to a Workstation</a>.</p>
<p>This article got me started with enabling the &#8220;aero&#8221; theme, <a edition?="Edition?" Workstation="Workstation" enabled?="enabled?" aero="aero" target="_blank" href="http://softwareblogs.intel.com/2008/02/12/windows-server-2008-aero-enabled-workstation-edition/" title="Windows Server 2008 ">Windows Server 2008 &#8220;Aero Enabled&#8221; Workstation Edition</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2008/04/08/add-vista-themes-to-longhorn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing File Ownership In Vista and Longhorn</title>
		<link>http://elegantcode.com/2008/04/07/changing-file-ownership-in-vista-and-longhorn/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=changing-file-ownership-in-vista-and-longhorn</link>
		<comments>http://elegantcode.com/2008/04/07/changing-file-ownership-in-vista-and-longhorn/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 02:58:46 +0000</pubDate>
		<dc:creator>Alex Mueller</dc:creator>
				<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2008/04/07/changing-file-ownership-in-vista-and-longhorn/</guid>
		<description><![CDATA[While installing Notepad2 on my Longhorn box (WindowsServer2008) I ran into an issue with overwriting the original notepad due to a lack of permissions. I found Matt Berther&#8217;s article which helped me understand what files needed to be overwritten for use in Vista. While I ran into similar problems in Vista, I did not write [...]]]></description>
			<content:encoded><![CDATA[<p>While installing <a title="Notepad2" href="http://www.flos-freeware.ch/notepad2.html" target="_blank">Notepad2</a> on my Longhorn box (WindowsServer2008) I ran into an issue with overwriting the original notepad due to a lack of permissions. I found <a href="http://www.mattberther.com/2006/11/19/replacing-notepad-in-windows-vista/" target="_blank">Matt Berther&#8217;s article</a> which helped me understand what files needed to be overwritten for use in Vista. While I ran into similar problems in Vista, I did not write down my steps, so when it came time to rebuild my Longhorn development environment, I battled the same issues.</p>
<p>Vista and Longhorn both have increased security measures.&#160; Overwriting a system file like notepad.exe is more involved. While I can see their need for this added security, I do find it annoying. Regardless of whether or not you are installing Notepad2, as in this article, or you just need to reassign ownership of a file in Vista or Windows Server 2008, I hope this article helps alleviate some of the pain.</p>
<p>In following the <a href="http://www.mattberther.com/2006/11/19/replacing-notepad-in-windows-vista/" target="_blank">article</a> on overwriting notepad.exe with notepad2.exe, I first came across the issue of granting full control rights for this file to my logged in user. Since I have had to figure this process out more than once now, I am deciding to document it, with wonderful screen-shots.</p>
<p>While granting full control to the administrator, I was alerted with the following dialog.</p>
<p><a href="http://elegantcode.com/wp-content/uploads/2008/04/image8.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2008/04/image-thumb8.png" width="354" height="156" /></a> </p>
<p>In order to overwrite a file, like notepad.exe, we need to give the administrator &quot;Full control.&quot; In order to do this, we need to change ownership of the file from &quot;TrustedInstaller&quot; to &quot;Administrators.&quot; TrustedInstaller, by default, has full control, while the admin account does not. </p>
<p>Right click the target file, click Properties.</p>
<p><a href="http://elegantcode.com/wp-content/uploads/2008/04/image9.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2008/04/image-thumb9.png" width="276" height="325" /></a> </p>
<p>Click on the security tab. You should see the &quot;Administrators&quot; account, by default, with read and execute permissions only.</p>
<p><a href="http://elegantcode.com/wp-content/uploads/2008/04/image10.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2008/04/image-thumb10.png" width="355" height="484" /></a> </p>
<p>Click on the &quot;Administrators&quot; account, seen above, then click on &quot;Advanced&quot; as pictured below.</p>
<p>&#160;</p>
<p> <a href="http://elegantcode.com/wp-content/uploads/2008/04/image11.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2008/04/image-thumb11.png" width="538" height="404" /></a>
<p>Next, we need to select the account for which we wish to edit owner permissions. Select the &quot;Owner&quot; tab. We should see &quot;TrustedInstaller&quot; highlighted as the current owner. </p>
<p><a href="http://elegantcode.com/wp-content/uploads/2008/04/image12.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2008/04/image-thumb12.png" width="539" height="405" /></a> </p>
<p>Click the &quot;Edit&#8230;&quot; button to change the owner of the file. The owner settings dialog should appear. Select the &quot;Administrators&quot; account, and click &quot;Apply.&quot; After clicking apply, there should be a prompt as shown below.</p>
<p><a href="http://elegantcode.com/wp-content/uploads/2008/04/image13.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2008/04/image-thumb13.png" width="414" height="156" /></a> </p>
<p>Finally, click &quot;OK.&quot; Then click &quot;OK&quot; to close the owner dialog. Click &quot;OK&quot; to save and exit the &quot;Advanced Security Settings for &lt;YourFileName.extension&gt;.&quot;</p>
<p>Next, we want to allow &quot;Full control&quot; for the admin account. After closing the last dialog, we should still see the properties dialog for our file (the original dialog view, the second screen-shot in this series). Select the &quot;Administrators&quot; account, and click &quot;Edit.&quot;</p>
<p>Give our &quot;Administrators&quot; account full control by enabling the checkboxes. </p>
<p><a href="http://elegantcode.com/wp-content/uploads/2008/04/image14.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2008/04/image-thumb14.png" width="371" height="447" /></a> </p>
<p>When you click &quot;Apply&quot; to apply these changes, the following prompt should be displayed. Click &quot;Yes&quot; to apply these changes to to grant full control to the administrator account.</p>
<p><a href="http://elegantcode.com/wp-content/uploads/2008/04/image15.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2008/04/image-thumb15.png" width="396" height="156" /></a> </p>
<p>At this point, the ownership of this file should have changed from the default &quot;TrustedInstaller,&quot; to the &quot;Administrators&quot; group. For me, I can now overwrite this notepad.exe file with the more useful notepad2.exe.</p>
<p>I hope this article helps. Until Vista and Longhorn become second-nature, I know I will be referencing this.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2008/04/07/changing-file-ownership-in-vista-and-longhorn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Discovering Windows PowerShell</title>
		<link>http://elegantcode.com/2008/03/27/discovering-windows-powershell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=discovering-windows-powershell</link>
		<comments>http://elegantcode.com/2008/03/27/discovering-windows-powershell/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 04:43:15 +0000</pubDate>
		<dc:creator>Alex Mueller</dc:creator>
				<category><![CDATA[Tools and Utilities]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2008/03/27/discovering-windows-powershell/</guid>
		<description><![CDATA[I am currently working in a new development environment, unlike any that I have used in the past. It is different for two reasons, magnitude of dependencies and build process. The warning I have been given is, &#34;this is a complex beast with lots of stuff in it, and much can go wrong.&#34; That statement [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently working in a new development environment, unlike any that I have used in the past. It is different for two reasons, magnitude of dependencies and build process. The warning I have been given is, &quot;this is a complex beast with lots of stuff in it, and much can go wrong.&quot; That statement pretty much covers the magnitude of dependencies stuff. As for the build process, my first question asked was, &quot;you mean we don&#8217;t use &#8216;Ctrl+Shift+B&#8217; (in Visual Studio)?&quot; No, we build using a command-line style approach, outside of the IDE.</p>
<p>Due the dependencies and build process, I wanted to schedule nightly builds on my local machines. This was when I discovered <a title="Windows PowerShell" href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target="_blank">Windows PowerShell</a>. PowerShell uses the .NET CLR and the .NET framework to provide new tools and methods for administering Windows environments. While similar in some aspects as DOS, PowerShell is much more. It is a command-line shell and scripting language that allows administrators to use C#.</p>
<p>Each night I want to backup certain files, sync files, clean and build my projects for 32 and 64 bit systems, update my environment with dependency changes, and email myself the log files generated during this process. I am not a DOS command nor scripting guru, but I could figure this out with some time. With PowerShell, I can leverage my C# knowledge to do all these tasks in a short amount of time.</p>
<p>If you want more control over administering your environments and would like to use C#, check out <a title="PowerShell" href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target="_blank">PowerShell</a>. There is a good amount of support and tutorials to help get started.</p>
<p><strong></strong></p>
<p><strong>Trivial Examples</strong></p>
<p>The following is a trivial example of how to connect to a SQL database, query the Employees table of the Northwind database, and write those results to the screen. The PowerShell scripting syntax can be seen below.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; padding-left: 4px; font-size: 8pt; border-top: gray 1px solid; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> $conn = New-Object System.Data.SqlClient.SqlConnection</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> $conn.ConnectionString = <span style="color: #006080">&quot;Data Source=.;Database=Northwind;&quot;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> $cmdText = <span style="color: #006080">&quot;SELECT TOP 10 * FROM EMPLOYEES&quot;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span> $conn.Open()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> $cmd = New-Object System.Data.SqlClient.SqlCommand($cmdText,$conn)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span> $rdr = $cmd.ExecuteReader()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> <span style="color: #0000ff">while</span>($rdr.Read())</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     $id = $rdr[<span style="color: #006080">&quot;EmployeeID&quot;</span>].ToString()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>     $fn = $rdr[<span style="color: #006080">&quot;FirstName&quot;</span>].ToString()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>     $ln = $rdr[<span style="color: #006080">&quot;LastName&quot;</span>].ToString()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     Write-Host <span style="color: #006080">&quot;$id $fn $ln&quot;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span> $conn.Close()</pre>
</p></div>
</div>
<p>While that example is extremely trivial, it does show the power of using C# logic with the PowerShell language. It is easy to see how the code example above was translated from C# into PowerShell. The differences are syntactic. </p>
<p>For my nightly build scenario, I am able to create a scheduled task that calls a batch file, with similar contents as below. </p>
<div style="border-right: gray 1px solid; padding-right: 4px; padding-left: 4px; font-size: 8pt; border-top: gray 1px solid; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> REM Calling Nightly Build</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> REM <span style="color: #0000ff">do</span> the necessary to clean and build my environment</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> call MyBuildLogicFile.bat</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> REM call powershell scripts</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span> powershell -command &quot;&amp; C:\PowerShellScripts\MyBuildScript.ps1</pre>
</p></div>
</div>
<p>The batch file does the building then calls a PowerShell script I created to do help me parse my log files and email the contents. It actually call two scripts, one for parsing the content of my resulting log file, and the other to email the contents of the log file. The contents of the two files can be seen below.</p>
<p>PowerShell provides a number of predefined methods that can be used out of the box. Since I am interested in reading a log file, parsing its contents, and emailing the results, there are some functions available for making this scenario easier. For example, I do not need to recreate the wheel to read in a file&#8217;s contents. I can use Get-Content. Before getting carried away with writing too much C#, check the available cmdlets (commandlets) to see if your desired functionality exists.</p>
<p>My file content parser script, using Get-Content.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; padding-left: 4px; font-size: 8pt; border-top: gray 1px solid; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> # Create a StringBuilder to retain our log file contents</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> $sb = <span style="color: #0000ff">new</span>-<span style="color: #0000ff">object</span> System.Text.StringBuilder</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> # append a line <span style="color: #0000ff">break</span> point, &lt;br/&gt; <span style="color: #0000ff">for</span> the log file contents</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span> <span style="color: #0000ff">foreach</span> ($line <span style="color: #0000ff">in</span> get-content <span style="color: #006080">&quot;C:\Output.log&quot;</span>)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>   $sb.Append($line).Append(<span style="color: #006080">&quot;&lt;br/&gt;&quot;</span>)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> # Call our Emailer.ps1 to send <span style="color: #0000ff">this</span> content to us</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> powershell -command <span style="color: #006080">&quot;&amp; C:\PowerShellScripts\Emailer.ps1 -param '$sb'&quot;</span></pre>
</p></div>
</div>
<p>My email script that is called from the above code.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; padding-left: 4px; font-size: 8pt; border-top: gray 1px solid; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> param($param1) </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> $message = <span style="color: #0000ff">new</span>-<span style="color: #0000ff">object</span> System.Net.Mail.MailMessage(<span style="color: #006080">&quot;me@mail.com&quot;</span>, <span style="color: #006080">&quot;me@mail.com&quot;</span>)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> $message.IsBodyHtml = $True</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span> $message.Subject = <span style="color: #006080">&quot;Automated Build Update&quot;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> $message.Body += $param1;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span> $smtp = <span style="color: #0000ff">new</span>-<span style="color: #0000ff">object</span> Net.Mail.SmtpClient(&#8221;smtp.mail.com&#8221;, 587) </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> $smtp.EnableSsl = $True</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> $smtp.Credentials = <span style="color: #0000ff">new</span>-<span style="color: #0000ff">object</span> System.Net.NetworkCredential(<span style="color: #006080">&quot;username&quot;</span>, <span style="color: #006080">&quot;password&quot;</span>)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> $smtp.Send($message)</pre>
</p></div>
</div>
<p>&#160;</p>
<p>Pretty simple. Thanks to PowerShell, I have more control over administering my development and test environments using my preexisting knowledge of C#. One command that was always useful in Unix/Linux is grep. PowerShell uses Regex to simulate similar functionality, and you can find examples of those online.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2008/03/27/discovering-windows-powershell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft 2008 Server</title>
		<link>http://elegantcode.com/2008/03/25/microsoft-2008-server/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=microsoft-2008-server</link>
		<comments>http://elegantcode.com/2008/03/25/microsoft-2008-server/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 16:12:23 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2008/03/25/microsoft-2008-server/</guid>
		<description><![CDATA[Is it 2008? I am just checking because I thought maybe it would be high time to bake in the ability to mount an ISO into a modern operating system. You know, like OS X does. Seriously! And don&#8217;t think I don&#8217;t realize I am sounding like a turtle neck wearing, smug, metrosexual developer. Dang [...]]]></description>
			<content:encoded><![CDATA[<p>Is it 2008? I am just checking because I thought maybe it would be high time to bake in the ability to mount an ISO into a modern operating system. You know, like OS X does. </p>
<p>Seriously! And don&#8217;t think I don&#8217;t realize I am sounding like a turtle neck wearing, smug, metrosexual developer. Dang it, I hate that, too!</p>
<p>This may be a pet peeve, but c&#8217;mon! I just want to mount an ISO without downloading 3rd party software and instead I get Texas Hold&#8217;em baked into the OS installer disk?</p>
<p>AAAaaaaargh&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2008/03/25/microsoft-2008-server/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Windows Backup and Restore on Vista</title>
		<link>http://elegantcode.com/2007/11/21/windows-backup-and-restore-on-vista/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=windows-backup-and-restore-on-vista</link>
		<comments>http://elegantcode.com/2007/11/21/windows-backup-and-restore-on-vista/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 02:17:56 +0000</pubDate>
		<dc:creator>David Starr</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2007/11/21/windows-backup-and-restore-on-vista/</guid>
		<description><![CDATA[This is a shout out to my homies on the Vista Backup and Restore Center Team (if such a team exists). I never would have believed it would work so well, and it did. I am running Vista + Mac OS X with Boot Camp. I installed VS 2008 Architecture Edition Monday only to learn [...]]]></description>
			<content:encoded><![CDATA[<p>This is a shout out to my homies on the Vista Backup and Restore Center Team (if such a team exists). I never would have believed it would work so well, and it did.</p>
<p>I am running Vista + Mac OS X with Boot Camp. I installed VS 2008 Architecture Edition Monday only to learn that edition of Visual Studio doesn&#8217;t support unit testing. Of course I wanted it off, but uninstall Visual Studio? You might as well reinstall the OS for all the goo VS seems typically leaves behind.</p>
<p>Luckily, I created a restore point before installing VS2008 in anticipation of something not working out well (oh me of little faith). One does that easily enough:</p>
<ol>
<li>Start &gt; Backup and Restore Center</li>
<li>Select the &quot;Create a Restore Point&quot; in the side menu.
<p><a href="http://elegantcode.com/wp-content/uploads/2007/11/image10.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="226" alt="image" src="http://elegantcode.com/wp-content/uploads/2007/11/image-thumb10.png" width="244" border="0" /></a> </li>
<li>This gives you dialog allowing you select the drive you want to create a restore point for.</li>
<li>Install Visual Studio 2008 for Architects Edition</li>
<li>Start &gt; Backup and Restore Center</li>
<li>At the bottom of the screen select:     <br /><a href="http://elegantcode.com/wp-content/uploads/2007/11/image11.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="56" alt="image" src="http://elegantcode.com/wp-content/uploads/2007/11/image-thumb11.png" width="414" border="0" /></a></li>
<li>Select the &quot;Choose a restore point&quot; option and get the dialog showing all of your restore points.     <br /><a href="http://elegantcode.com/wp-content/uploads/2007/11/image12.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="196" alt="image" src="http://elegantcode.com/wp-content/uploads/2007/11/image-thumb12.png" width="244" border="0" /></a></li>
<li>Click next and pray.</li>
<li>Go eat dinner.</li>
<li>Come back after dinner and login. It&#8217;s bloody magic!</li>
<li>Install Visual Studio 2008 Team Suite.</li>
<li>Blog about it.&#160; </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2007/11/21/windows-backup-and-restore-on-vista/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

