<?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>Chinh Do &#187; Programming</title>
	<atom:link href="http://www.chinhdo.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chinhdo.com</link>
	<description>Chinh's not quite random thoughts on software development, .NET, gadgets, and other things.</description>
	<lastBuildDate>Sat, 06 Aug 2011 21:04:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Transactional File Manager Version 1.2 .1 Released</title>
		<link>http://www.chinhdo.com/20110806/transactional-file-manager-version-1-2-released/</link>
		<comments>http://www.chinhdo.com/20110806/transactional-file-manager-version-1-2-released/#comments</comments>
		<pubDate>Sat, 06 Aug 2011 21:04:14 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Dotnet/.NET - C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20110806/transactional-file-manager-version-1-2-released/</guid>
		<description><![CDATA[Version 1.2 of Transactional File Manager is now available on CodePlex. Here’s the release notes: Release Notes This is a minor bug-fix/minor refactor release. Fixes: Copy now uses the overwrite parameter correctly. Fixes crashing problem on some machines due to use of GetsequentialGuid. CreateDirectory now supports rolling back nested directories. RollbackFile Rollback() may throw exception [...]]]></description>
			<content:encoded><![CDATA[<p>Version 1.2 of Transactional File Manager is <a href="http://transactionalfilemgr.codeplex.com/releases/view/46998">now available on CodePlex</a>.</p>
<p>Here’s the release notes:</p>
<h5>Release Notes</h5>
<p>This is a minor bug-fix/minor refactor release.   <br /><b>Fixes:</b></p>
<ul>
<li>Copy now uses the overwrite parameter correctly. </li>
<li>Fixes crashing problem on some machines due to use of GetsequentialGuid. </li>
<li>CreateDirectory now supports rolling back nested directories. </li>
<li>RollbackFile Rollback() may throw exception when original directory has been deleted. </li>
<li>Security issue when writing to event logs.</li>
</ul>
<p><b>Enhancements:</b>
<ul>
<li>Upgrade solution/project files to Visual Studio 2010 </li>
<li>Use NUnit instead of VSTS framework </li>
<li>Changes to support Visual Studio Express</li>
</ul>
<p>Thanks to karbuke and dorong for their contributions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20110806/transactional-file-manager-version-1-2-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WBR HTML Tag</title>
		<link>http://www.chinhdo.com/20110113/wbr-html-tag/</link>
		<comments>http://www.chinhdo.com/20110113/wbr-html-tag/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 02:02:46 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20110113/wbr-html-tag/</guid>
		<description><![CDATA[The little known WBR tag is great for formatting HTML tables. Add it to specific places in your table cell values to give the browser the option to add a line break there. This is very useful when displaying tables with long strings that would otherwise cause horizontal scrolling. Here’s a sample table, displaying some [...]]]></description>
			<content:encoded><![CDATA[<p>The little known WBR tag is great for formatting HTML tables. Add it to specific places in your table cell values to give the browser the option to add a line break there. This is very useful when displaying tables with long strings that would otherwise cause horizontal scrolling.</p>
<p>Here’s a sample table, displaying some info. Since the values in the tables do not have spaces or tabs, the browser is forced to display the values on one line:</p>
<table cellspacing="2" cellpadding="2" width="100" style="border: black 1px solid">
<tbody>
<tr>
<td valign="top" style="border: black 1px solid">Key</td>
<td valign="top" style="border: black 1px solid">Value</td>
</tr>
<tr>
<td valign="top" style="border: black 1px solid">ChinhDo.TestApp.TestClass.ExampleKey1</td>
<td valign="top" style="border: black 1px solid">this.is.an.example.of.a.very.long.string</td>
</tr>
</tbody>
</table>
<p>Here&#8217;s the same table, with &lt;wbr/&gt; tags inserted where periods are:</p>
<table border="1" cellspacing="2" cellpadding="2" width="100" style="border: black 1px solid">
<tbody>
<tr>
<td valign="top" style="border: black 1px solid">Key</td>
<td valign="top" style="border: black 1px solid">Value</td>
</tr>
<tr>
<td valign="top" style="border: black 1px solid">ChinhDo.<wbr></wbr>TestApp.<wbr></wbr>TestClass.<wbr></wbr>ExampleKey1</td>
<td valign="top" style="border: black 1px solid">this.<wbr></wbr>is.<wbr></wbr>an.<wbr></wbr>example.<wbr></wbr>of.<wbr></wbr>a.<wbr></wbr>very.<wbr></wbr>long.<wbr></wbr>string</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20110113/wbr-html-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting the Starting Day of the Week for Any Date</title>
		<link>http://www.chinhdo.com/20100907/getting-the-starting-day-of-the-week-for-any-date/</link>
		<comments>http://www.chinhdo.com/20100907/getting-the-starting-day-of-the-week-for-any-date/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 23:33:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Dotnet/.NET - C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100907/getting-the-starting-day-of-the-week-for-any-date/</guid>
		<description><![CDATA[From my code snippets, here’s a function that will return the starting day of the week for any date: /// &#60;summary&#62; /// Gets the start of the week that contains the specified date. /// &#60;/summary&#62; /// &#60;param name=&#34;date&#34;&#62;The date.&#60;/param&#62; /// &#60;param name=&#34;weekStartsOn&#34;&#62;The day that each week starts on.&#60;/param&#62; /// &#60;returns&#62;The start date of the week.&#60;/returns&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>From my code snippets, here’s a function that will return the starting day of the week for any date:</p>
<pre class="brush: csharp;">
/// &lt;summary&gt;
/// Gets the start of the week that contains the specified date.
/// &lt;/summary&gt;
/// &lt;param name=&quot;date&quot;&gt;The date.&lt;/param&gt;
/// &lt;param name=&quot;weekStartsOn&quot;&gt;The day that each week starts on.&lt;/param&gt;
/// &lt;returns&gt;The start date of the week.&lt;/returns&gt;
public static DateTime GetStartOfWeek(DateTime date, DayOfWeek weekStartsOn)
{
    int days = date.DayOfWeek - weekStartsOn;
    DateTime startOfWeek = days&gt;=0 ? date.AddDays(-days) : date.AddDays(-7 - days);
    return startOfWeek;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100907/getting-the-starting-day-of-the-week-for-any-date/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Transactional File Manager Is Now On CodePlex</title>
		<link>http://www.chinhdo.com/20100608/transactional-file-manager-is-now-on-codeplex/</link>
		<comments>http://www.chinhdo.com/20100608/transactional-file-manager-is-now-on-codeplex/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 22:38:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Dotnet/.NET - C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100608/transactional-file-manager-is-now-on-codeplex/</guid>
		<description><![CDATA[It’s my first open source project! I’ve gone open source with my Transactional File Manager. Check out the CodePlex link here. Use any file system as a transactional file system! Transactional File Manager is a .NET API that supports including file system operations such as file copy, move, delete in a transaction. It&#8217;s an implementation [...]]]></description>
			<content:encoded><![CDATA[<p>It’s my first open source project! I’ve gone open source with my Transactional File Manager. Check out the CodePlex link <a href="http://transactionalfilemgr.codeplex.com/" target="_blank">here</a>.</p>
<p>Use any file system as a transactional file system! Transactional File Manager is a .NET API that supports including file system operations such as file copy, move, delete in a transaction. It&#8217;s an implementation of System.Transaction.IEnlistmentNotification (works with System.Transactions.TransactionScope).</p>
<p><a href="http://transactionalfilemgr.codeplex.com/"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.chinhdo.com/wp-content/uploads/2010/06/image_thumb.png" width="505" height="234" /></a></p>
<p>More on Transactional File Manager in my original blog <a href="http://www.chinhdo.com/20080825/transactional-file-manager/" target="_blank">post</a> on it. If you are interested in contributing to the project, let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100608/transactional-file-manager-is-now-on-codeplex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MSMQ Installation on Windows Server 2008 Fail with 0&#215;80070643</title>
		<link>http://www.chinhdo.com/20100510/msmq-installation-on-windows-server-2008-fail-with-0x80070643/</link>
		<comments>http://www.chinhdo.com/20100510/msmq-installation-on-windows-server-2008-fail-with-0x80070643/#comments</comments>
		<pubDate>Tue, 11 May 2010 01:49:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Dotnet/.NET - C#]]></category>
		<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100515/msmq-installation-on-windows-server-2008-fail-with-0x80070643/</guid>
		<description><![CDATA[If you get one of these errors starting MSMQ Server or installing MSMQ on Windows (Server 2008), this article describes a potential solution: You cannot start MSMQ Service with the following entry in the Application Event Log: The Message Queuing service cannot start. The internal private queue &#8216;admin_queue$&#8217; cannot be initialized. If the problem persists, [...]]]></description>
			<content:encoded><![CDATA[<p>If you get one of these errors starting MSMQ Server or installing MSMQ on Windows (Server 2008), this article describes a potential solution:</p>
<ul>
<li>You cannot start MSMQ Service with the following entry in the Application Event Log: The Message Queuing service cannot start. The internal private queue &#8216;admin_queue$&#8217; cannot be initialized. If the problem persists, reinstall Message Queuing. Error 0xc00e0001.</li>
<li>You cannot install MSMQ with the following error: Attempt to install Message Queuing Server failed with error code 0&#215;80070643. Fatal error during installation. The following features were not installed: Message Queuing Services/Message Queuing Server.
<p><a href="http://www.chinhdo.com/wp-content/uploads/2010/05/2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="MSMQ Installation Result" border="0" alt="MSMQ Installation Result" src="http://www.chinhdo.com/wp-content/uploads/2010/05/2_thumb.png" width="575" height="434" /></a> </li>
</ul>
<p>&#160;</p>
<p>For me, the solution was to delete the Registry key KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSMQ, then try the installation again.</p>
<h4>See also:</h4>
<ul>
<li><a href="http://blogs.msdn.com/johnbreakwell/archive/2009/06/04/msmq-won-t-install-on-windows-2008-with-a-fatal-error-0x80070643.aspx">MSMQ won&#8217;t install on Windows 2008 with a Fatal Error (0&#215;80070643)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100510/msmq-installation-on-windows-server-2008-fail-with-0x80070643/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t hire ghost hunters who are afraid of ghosts</title>
		<link>http://www.chinhdo.com/20100327/event-viewer-dependency-on-dotnet/</link>
		<comments>http://www.chinhdo.com/20100327/event-viewer-dependency-on-dotnet/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 04:26:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Dotnet/.NET - C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100327/event-viewer-dependency-on-dotnet/</guid>
		<description><![CDATA[Your house is haunted. You can’t stand living with the ghosts anymore and decide to call in the professional, a ghost hunter. The ghost hunter comes, nicely equipped with all kinds of shiny ghost hunting equipment, and proceeds to immediately pass out and fall to to the floor with a loud thud at first sight [...]]]></description>
			<content:encoded><![CDATA[<p>Your house is haunted. You can’t stand living with the ghosts anymore and decide to call in the professional, a ghost hunter. The ghost hunter comes, nicely equipped with all kinds of shiny ghost hunting equipment, and proceeds to immediately pass out and fall to to the floor with a loud thud at first sight of the ghosts.</p>
<p>Well, in a nutshell, that is the story of the new Event Viewer in Windows Vista and Windows Server 2008. The new Event Viewer looks very nice and all. Trouble is, it now won’t work when there is a syntax error in machine.config or other .NET Framework problems. Apparently, in Windows Vista and Windows 2008, someone at Microsoft decided to rewrite the Event Viewer utility (a perfectly usable and solid utility in previous versions of Windows) in .NET.</p>
<p><a href="http://www.chinhdo.com/wp-content/uploads/2010/03/image.png"><img title="MMC could not create the snap-in. The snap-in might not have been installed correctly. Name: Event Viewer." style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="253" alt="MMC could not create the snap-in. The snap-in might not have been installed correctly. Name: Event Viewer." src="http://www.chinhdo.com/wp-content/uploads/2010/03/image_thumb.png" width="450" border="0" /></a> </p>
<p>So, the lesson I learned from this is: don’t hire ghost hunters who are afraid of ghosts. Or, don’t write a utility designed to view monitoring and troubleshooting messages that can fail due to unnecessary dependencies. A critical system troubleshooting utility such as Event Viewer should be the last thing that fails.</p>
<h3>What to do when you cannot run Event Viewer in Windows Vista/Windows Server 2008/or Windows 7?</h3>
<p>If you get the following error:</p>
<blockquote><p>MMC could not create the snap-in. The snap-in might now have been installed correctly. Name: Event Viewer. CLSID: FX:{b05566ad-fe9c-4363-be05-7a4cbb7cb510}</p>
</blockquote>
<p>Try the following:</p>
<ul>
<li>Fix any syntax errors in machine.config. Restore to a previously known working copy.</li>
<li>Rename EventVwr.exe.config in %WINDIR%\System32.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100327/event-viewer-dependency-on-dotnet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL Server Implicit String Conversion/Concatenation (XML parsing: line &lt;x&gt;, character &lt;y&gt;, unexpected end of input)</title>
		<link>http://www.chinhdo.com/20100220/sql-server-concatenation/</link>
		<comments>http://www.chinhdo.com/20100220/sql-server-concatenation/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 18:32:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100220/sql-server-concatenation/</guid>
		<description><![CDATA[If you are getting this error in your SQL Server T-SQL script:, you may be running into an issue with implicit string conversion in SQL Server: declare @xml varchar(max), @doc XML, @stringVariable varchar(256) set @stringVariable = 'a string value' -- @doc is set by concatenating multiple string literals -- and string variables, with all the [...]]]></description>
			<content:encoded><![CDATA[<p>If you are getting this error in your SQL Server T-SQL script:, you may be running into an issue with implicit string conversion in SQL Server:</p>
<pre class="brush: sql;">declare @xml varchar(max), @doc XML, @stringVariable varchar(256)
set @stringVariable = 'a string value'

-- @doc is set by concatenating multiple string literals
-- and string variables, with all the variables having less than
-- or equal to 8000 characters
set @xml = '&lt;root&gt;' +
... + @stringVariable +
...
'&lt;/root&gt;'

print len(@xml)

set @doc = @xml</pre>
<p><strong>Output</strong> </p>
<pre style="padding-left: 15px; font-family: monospace">8000
<font color="#ff0000">Msg 9400, Level 16, State 1, Line 4
XML parsing: line 64, character 74, unexpected end of input</font></pre>
<p>As you can see in the output, the @xml variable was truncated to 8000 characters, resulting in an invalid XML. This is due to the way SQL Server performs implicit string conversions when concatenating strings. When all the string literals/variables involved in the concatenation are 8000 characters or less, the resulting string will be exactly 8000 characters.</p>
<p>The same issue occurs with NVARCHAR data type. Instead of the 8000-character limit, it’s 4000 characters.</p>
<p>A simple fix is to make sure at least one of the string variables is of type VARCHAR(MAX):</p>
<pre class="brush: sql;">declare @xml varchar(max), @doc XML, @stringVariable varchar(256)
declare @x varchar(max)

set @stringVariable = 'a string value'
set @x = ''

set @xml = @x + '&lt;root&gt;' +
... + @stringVariable +
...
'&lt;/root&gt;'

print len(@xml)

set @doc = @xml</pre>
<p>&#160;</p>
<h3>More Info</h3>
<ul>
<li><a href="http://hrubaru.blogspot.com/2010/01/string-concatenation-issues.html">String Concatenation Issues</a> (Hrubaru&#8217;s blog) </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100220/sql-server-concatenation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a Different Configured Binding in WCF Client</title>
		<link>http://www.chinhdo.com/20100206/wcf-switch-binding/</link>
		<comments>http://www.chinhdo.com/20100206/wcf-switch-binding/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 23:38:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Dotnet/.NET - C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100206/wcf-switch-binding/</guid>
		<description><![CDATA[To programmatically switch bindings on the fly, you can do it via the constructor of the generated client: var client = new WeatherClient(“MyEndpoint”); “MyEndpoint” is the name of the endpoint defined in your config file: &#60;client&#62; &#60;endpoint address=&#34;&#34; binding=&#34;basicHttpBinding&#34; bindingConfiguration=&#34;http1&#34; contract=&#34;MyContract&#34; name=&#34;MyEndpoint&#34; /&#62; &#60;/client&#62;]]></description>
			<content:encoded><![CDATA[<p>To programmatically switch bindings on the fly, you can do it via the constructor of the generated client:</p>
<pre class="brush: csharp;">var client = new WeatherClient(“MyEndpoint”);</pre>
<p>“MyEndpoint” is the name of the endpoint defined in your config file:</p>
<pre class="brush: xml;">&lt;client&gt;
    &lt;endpoint address=&quot;&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;http1&quot; contract=&quot;MyContract&quot; name=&quot;MyEndpoint&quot; /&gt;</pre>
<pre class="brush: xml;">&lt;/client&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100206/wcf-switch-binding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WCF Client Error “The connection was closed unexpectedly” Calling Java/WebSphere 7 Web Service</title>
		<link>http://www.chinhdo.com/20100123/wcf-java-100-continue/</link>
		<comments>http://www.chinhdo.com/20100123/wcf-java-100-continue/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 01:31:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[Dotnet/.NET - C#]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100127/wcf-java-100-continue/</guid>
		<description><![CDATA[If you get the following exception calling a WebSphere web service from your .NET WCF Client (service reference): System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly. &#8212;&#62;  System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly. Try adding this code before the service call: System.Net.ServicePointManager.Expect100Continue = false; More info on [...]]]></description>
			<content:encoded><![CDATA[<p>If you get the following exception calling a WebSphere web service from your .NET WCF Client (service reference):</p>
<blockquote><p>System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly. &#8212;&gt;  System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.</p></blockquote>
<p>Try adding this code before the service call:</p>
<pre class="brush: csharp;">System.Net.ServicePointManager.Expect100Continue = false;</pre>
<p><a href="http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.expect100continue.aspx">More info</a> on the 100-Continue behavior from MSDN.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100123/wcf-java-100-continue/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Give The Power of Speech and Sound to Your PowerShell Scripts</title>
		<link>http://www.chinhdo.com/20100116/give-the-power-of-speech-and-sound-to-your-powershell-scripts/</link>
		<comments>http://www.chinhdo.com/20100116/give-the-power-of-speech-and-sound-to-your-powershell-scripts/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 05:34:00 +0000</pubDate>
		<dc:creator>Chinh Do</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.chinhdo.com/20100120/give-the-power-of-speech-and-sound-to-your-powershell-scripts/</guid>
		<description><![CDATA[Do you ever have the problem where you start a long running script (such as running a code build), multi-task on something else on another monitor while waiting for the script to finish, and then totally forget about the script until half an hour later? Well, here’s a solution your problem: have your script give [...]]]></description>
			<content:encoded><![CDATA[<p>Do you ever have the problem where you start a long running script (such as running a code build), multi-task on something else on another monitor while waiting for the script to finish, and then totally forget about the script until half an hour later? Well, here’s a solution your problem: have your script give you holler at you when it’s done.</p>
<p><img title="Hello sir! I am done running your command!" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="224" alt="Hello sir! I am done running your command!" src="http://www.chinhdo.com/wp-content/uploads/2010/01/image1.png" width="279" border="0" /> </p>
<p>In my library script file, I have the following functions to play sound files and to speak any text:</p>
<pre class="brush: csharp;">function PlayMp3($path) {
    # Use the default player to play. Hide the window.
    $si = new-object System.Diagnostics.ProcessStartInfo
    $si.fileName = $path
    $si.windowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
    $process = New-Object System.Diagnostics.Process
    $process.startInfo=$si
    $process.start()
}

function PlayWav($path) {
    $sound = new-Object System.Media.SoundPlayer;
    $sound.SoundLocation=&quot;$path&quot;;
    $sound.Play();
}

function Say($msg) {
    $Voice = new-object -com SAPI.SpVoice
    $Voice.Speak($msg, 1 )
}</pre>
<p>If you like the text-to-speech feature but find Windows’ speech engine lacking, check out <a href="http://www.ivona.com/?tk=jtvleiDF">Ivona</a>. It’s a commercial text-to-speech engine but you are allow to generate and download short speech files for free personal use. Now, my script can nicely interrupt me to tell me when it’s done. Other online text-to-speech engines: <a href="http://vozme.com/index.php?lang=en">vozMe</a>, <a href="http://spokentext.net/">SpokenText</a>.</p>
<h3>If Making Noise Is Not Your Thing</h3>
<p>If making noise is not your thing, consider displaying a message in the Notification Area. Here’s the code (courtesy <a href="http://www.microsoft.com/technet/scriptcenter/resources/pstips/may08/pstip0523.mspx">Microsoft TechNet</a>):</p>
<p><img title="Build complete!" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="96" alt="Build complete!" src="http://www.chinhdo.com/wp-content/uploads/2010/01/x.jpg" width="209" border="0" /> </p>
<pre class="brush: csharp;">function Get-ScriptName {
    $MyInvocation.ScriptName
} 

function DisplayNotificationInfo($msg, $title, $type) {
    # $type - &quot;info&quot; or &quot;error&quot;
    if ($type -eq $null) {$type = &quot;info&quot;}
    if ($title -eq $null) {$title = Get-ScriptName}

    [void] [System.Reflection.Assembly]::LoadWithPartialName(&quot;System.Windows.Forms&quot;)
    $objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon
    # Specify your own icon below
    $objNotifyIcon.Icon = &quot;C:CdoScriptsFolder.ico&quot;
    $objNotifyIcon.BalloonTipIcon = &quot;Info&quot;
    $objNotifyIcon.BalloonTipTitle = $title
    $objNotifyIcon.BalloonTipText = $msg

    $objNotifyIcon.Visible = $True
    $objNotifyIcon.ShowBalloonTip(10000)
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.chinhdo.com/20100116/give-the-power-of-speech-and-sound-to-your-powershell-scripts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

