<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>All About Interop : Powershell</title><link>http://blogs.msdn.com/dotnetinterop/archive/tags/Powershell/default.aspx</link><description>Tags: Powershell</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>More on PowerShell Interop - this time with Tibco EMS</title><link>http://blogs.msdn.com/dotnetinterop/archive/2008/07/02/more-on-powershell-interop-this-time-with-tibco-ems.aspx</link><pubDate>Wed, 02 Jul 2008 17:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8680478</guid><dc:creator>DotNetInterop</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dotnetinterop/comments/8680478.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dotnetinterop/commentrss.aspx?PostID=8680478</wfw:commentRss><description>&lt;P&gt;Keeping on the theme of PowerShell interop....&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://magmasystems.blogspot.com/" mce_href="http://magmasystems.blogspot.com"&gt;Marc Adler&lt;/A&gt; wrote up a short, sweet little &lt;A class="" href="http://magmasystems.blogspot.com/2008/06/tibco-ems-powershell-cmdlet.html" mce_href="http://magmasystems.blogspot.com/2008/06/tibco-ems-powershell-cmdlet.html"&gt;CmdLet for querying TIBCO EMS&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;And he separately referenced a CmdLet by &lt;A class="" href="http://weblogs.asp.net/sweinstein" mce_href="http://weblogs.asp.net/sweinstein"&gt;Scott Weinstein&lt;/A&gt; for &lt;A class="" href="http://weblogs.asp.net/sweinstein/archive/2008/06/20/coral8-stream-reader-in-powershell.aspx" mce_href="http://weblogs.asp.net/sweinstein/archive/2008/06/20/coral8-stream-reader-in-powershell.aspx"&gt;connecting PowerShell to Coral8&lt;/A&gt;. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8680478" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Interop/default.aspx">Interop</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Powershell/default.aspx">Powershell</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/TIBCO/default.aspx">TIBCO</category></item><item><title>PowerShell CMDLets for WebSphere MQ - administer queues on Windows or Linux</title><link>http://blogs.msdn.com/dotnetinterop/archive/2008/06/30/powershell-cmdlets-for-websphere-mq.aspx</link><pubDate>Tue, 01 Jul 2008 00:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8673308</guid><dc:creator>DotNetInterop</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dotnetinterop/comments/8673308.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dotnetinterop/commentrss.aspx?PostID=8673308</wfw:commentRss><description>&lt;P&gt;Last year, I &lt;A class="" href="http://blogs.msdn.com/dotnetinterop/archive/2007/02/16/ibm-s-mq-blog-includes-some-good-net-stuff.aspx" mce_href="http://blogs.msdn.com/dotnetinterop/archive/2007/02/16/ibm-s-mq-blog-includes-some-good-net-stuff.aspx"&gt;wrote about&lt;/A&gt; &lt;EM&gt;the idea &lt;/EM&gt;of PowerShell CmdLets for WebSphere MQ.&amp;nbsp; PowerShell is a beautiful scripting environment, you see, and it allows you to load any managed class library and then call into it.&amp;nbsp; This is what allows me to, for example, &lt;A class="" href="http://blogs.msdn.com/dotnetinterop/archive/2008/06/26/zip-creation-within-powershell.aspx" mce_href="http://blogs.msdn.com/dotnetinterop/archive/2008/06/26/zip-creation-within-powershell.aspx"&gt;create zip files within Powershell&lt;/A&gt;.&amp;nbsp;&amp;nbsp;But there are of course a zillion other possibilities.&amp;nbsp; On the other hand if you are doing scripting, another opportunity for integration with PowerShell is &lt;A class="" href="http://msdn.microsoft.com/en-us/magazine/cc163293.aspx" mce_href="http://msdn.microsoft.com/en-us/magazine/cc163293.aspx"&gt;CmdLets&lt;/A&gt;.&amp;nbsp; CmdLets are little bits of function that get added to the Powershell base function.&amp;nbsp; All the capabilities within PowerShell are exposed via commands that have a verb-noun structure, like Get-ChildItem.&amp;nbsp; Or Write-Output.&amp;nbsp; If you create a new cmdlet and add it to PowerShell , you've added to its vocabulary of functions.&amp;nbsp; CmdLets offer better utility in a scripting environment, as compared to&amp;nbsp;just loading an assembly and calling into the loaded class library. &lt;/P&gt;
&lt;P&gt;It seems IBM have been busy doing CmdLets for MQ, and &lt;EM&gt;somehow this escaped my attention&lt;/EM&gt;.&amp;nbsp;Starting back in December 2007, Dale Lane at IBM published a series of posts about the topic of PowerShell CmdLets for MQ.&amp;nbsp; There is also now an &lt;EM&gt;&lt;A class="" href="http://www-1.ibm.com/support/docview.wss?rs=171&amp;amp;uid=swg24017698" mce_href="http://www-1.ibm.com/support/docview.wss?rs=171&amp;amp;uid=swg24017698"&gt;official SupportPac&lt;/A&gt;&lt;/EM&gt; for this stuff, it goes by the catchy name of mo74. (direct FTP link &lt;A class="" href="ftp://ftp.software.ibm.com/software/integration/support/supportpacs/individual/mo74.zip" mce_href="ftp://ftp.software.ibm.com/software/integration/support/supportpacs/individual/mo74.zip"&gt;here&lt;/A&gt;).&amp;nbsp;&amp;nbsp;&amp;nbsp; In IBM-speak, a SupportPac is an add-on to the IBM product (in this case WMQ).&amp;nbsp; Very good to see!&amp;nbsp; Keep in mind that there are different categories of SupportPac&amp;nbsp; and just because it says "support" in the name does not mean it is a "supported" part of the IBM product in the sense that you can call up their support engineers and ask for bugfix on it.&amp;nbsp;&amp;nbsp;mo74 is listed as Category 2, which means it is AS-IS software.&amp;nbsp; SupportPacs &lt;EM&gt;can &lt;/EM&gt;transition from "AS-IS" to a supported part of the product; this happens when customers demand it.&amp;nbsp; Last updated April 16th, mo74 is currently&amp;nbsp;at version 1.6.&amp;nbsp; &amp;nbsp; &lt;/P&gt;
&lt;P&gt;One of the things&amp;nbsp;you can do with the MQ cmdlets included in the mo74.zip SupportPac is administer queue managers on remote machines, including machines running MQ on Windows, Linux, or Unix. (If you know MQ, this shouldn't be too surprising, as&amp;nbsp;you know that MQ&amp;nbsp;can use the queue itself to send administrative commands.)&amp;nbsp;&amp;nbsp;IBM plans to add z/OS to the list of platforms that can be administered remotely using PowerShell.&amp;nbsp;&amp;nbsp;You can read about their plans and progress on integrating PowerShell with WMQ on the &lt;A class="" href="http://hursleyonwmq.wordpress.com/" mce_href="http://hursleyonwmq.wordpress.com/"&gt;"Hursley on MQ" blog&lt;/A&gt;.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;By the way, &lt;A class="" href="http://dalelane.co.uk/blog/?p=235" mce_href="http://dalelane.co.uk/blog/?p=235"&gt;Dale also has a personal blog&lt;/A&gt;, where he writes about a bunch of stuff, some&amp;nbsp;of which is&amp;nbsp;related&amp;nbsp; to PowerShell and&amp;nbsp;WMQ. &lt;/P&gt;
&lt;P&gt;It's good to see this integration.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8673308" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Interop/default.aspx">Interop</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/MQ/default.aspx">MQ</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/IBM/default.aspx">IBM</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Powershell/default.aspx">Powershell</category></item><item><title>Create Zip files within Powershell</title><link>http://blogs.msdn.com/dotnetinterop/archive/2008/06/26/zip-creation-within-powershell.aspx</link><pubDate>Fri, 27 Jun 2008 00:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8658510</guid><dc:creator>DotNetInterop</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dotnetinterop/comments/8658510.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dotnetinterop/commentrss.aspx?PostID=8658510</wfw:commentRss><description>&lt;P&gt;You can use DotNetZip library from within &lt;A class="" href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" mce_href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx"&gt;Powershell&lt;/A&gt;.&amp;nbsp; It's pretty simple, fast, easy. &lt;/P&gt;
&lt;P&gt;example:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 2pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 2pt; FONT-SIZE: 9pt; BACKGROUND: white; PADDING-BOTTOM: 2pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 2pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #a020f0"&gt;function&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;ZipUp-Files&lt;/SPAN&gt; ( &lt;SPAN style="COLOR: #b8860b"&gt;$directory&lt;/SPAN&gt; )
{

  &lt;SPAN style="COLOR: #b8860b"&gt;$children&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #0000ff"&gt;get-childitem&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-path&lt;/SPAN&gt; &lt;SPAN style="COLOR: #b8860b"&gt;$directory&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: #a020f0"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #b8860b"&gt;$o&lt;/SPAN&gt; in &lt;SPAN style="COLOR: #b8860b"&gt;$children&lt;/SPAN&gt;) 
  {
    &lt;SPAN style="COLOR: #a020f0"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #b8860b"&gt;$o.Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-ne&lt;/SPAN&gt; &lt;SPAN style="COLOR: #bc8f8f"&gt;"TestResults"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-and&lt;/SPAN&gt; 
        &lt;SPAN style="COLOR: #b8860b"&gt;$o.Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-ne&lt;/SPAN&gt; &lt;SPAN style="COLOR: #bc8f8f"&gt;"obj"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-and&lt;/SPAN&gt; 
        &lt;SPAN style="COLOR: #b8860b"&gt;$o.Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-ne&lt;/SPAN&gt; &lt;SPAN style="COLOR: #bc8f8f"&gt;"bin"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-and&lt;/SPAN&gt; 
        &lt;SPAN style="COLOR: #b8860b"&gt;$o.Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-ne&lt;/SPAN&gt; &lt;SPAN style="COLOR: #bc8f8f"&gt;"tfs"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-and&lt;/SPAN&gt; 
        &lt;SPAN style="COLOR: #b8860b"&gt;$o.Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-ne&lt;/SPAN&gt; &lt;SPAN style="COLOR: #bc8f8f"&gt;"notused"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-and&lt;/SPAN&gt; 
        &lt;SPAN style="COLOR: #b8860b"&gt;$o.Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-ne&lt;/SPAN&gt; &lt;SPAN style="COLOR: #bc8f8f"&gt;"Release"&lt;/SPAN&gt;)
    {
      &lt;SPAN style="COLOR: #a020f0"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #b8860b"&gt;$o.PSIsContainer&lt;/SPAN&gt;)
      {
        &lt;SPAN style="COLOR: #0000ff"&gt;ZipUp-Files&lt;/SPAN&gt; ( &lt;SPAN style="COLOR: #b8860b"&gt;$o.FullName&lt;/SPAN&gt; )
      }
      &lt;SPAN style="COLOR: #a020f0"&gt;else&lt;/SPAN&gt; 
      {
        &lt;SPAN style="COLOR: #a020f0"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #b8860b"&gt;$o.Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-ne&lt;/SPAN&gt; &lt;SPAN style="COLOR: #bc8f8f"&gt;".tfs-ignore"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-and&lt;/SPAN&gt;
           !&lt;SPAN style="COLOR: #b8860b"&gt;$o.Name.EndsWith&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #bc8f8f"&gt;".cache"&lt;/SPAN&gt;) &lt;SPAN style="COLOR: #228b22"&gt;-and&lt;/SPAN&gt;
           !&lt;SPAN style="COLOR: #b8860b"&gt;$o.Name.EndsWith&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #bc8f8f"&gt;".zip"&lt;/SPAN&gt;) )
        {
          &lt;SPAN style="COLOR: #0000ff"&gt;Write-output&lt;/SPAN&gt; &lt;SPAN style="COLOR: #b8860b"&gt;$o.FullName&lt;/SPAN&gt;
          &lt;SPAN style="COLOR: #b8860b"&gt;$e&lt;/SPAN&gt;= &lt;SPAN style="COLOR: #b8860b"&gt;$zipfile.AddFile&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #b8860b"&gt;$o.FullName&lt;/SPAN&gt;)
        }
      }
    }
  }
}


[System.Reflection.Assembly]::LoadFrom(&lt;SPAN style="COLOR: #bc8f8f"&gt;"c:\\\bin\\Ionic.Utils.Zip.dll"&lt;/SPAN&gt;);

&lt;SPAN style="COLOR: #b8860b"&gt;$zipfile&lt;/SPAN&gt; =  &lt;SPAN style="COLOR: #0000ff"&gt;new-object&lt;/SPAN&gt; Ionic.Utils.Zip.ZipFile(&lt;SPAN style="COLOR: #bc8f8f"&gt;"zipsrc.zip"&lt;/SPAN&gt;);

&lt;SPAN style="COLOR: #0000ff"&gt;ZipUp-Files&lt;/SPAN&gt; &lt;SPAN style="COLOR: #bc8f8f"&gt;"DotNetZip"&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #b8860b"&gt;$zipfile.Save&lt;/SPAN&gt;()

&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The example above shows how to create a zip.&amp;nbsp; I use it to zip up a directory containing source files, and I&amp;nbsp;leave out any unwanted files or&amp;nbsp;directories. Of course you can also extract a zip, view a zip, Update a zip, and so on.&amp;nbsp; &amp;nbsp;Anything you can do in the DotNetZip library, you can do in Powershell. &lt;/P&gt;
&lt;P&gt;Visit &lt;A href="http://www.codeplex.com/DotNetZip" mce_href="http://www.codeplex.com/DotNetZip"&gt;http://www.codeplex.com/DotNetZip&lt;/A&gt;&amp;nbsp; to get DotNetZip. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8658510" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Zip/default.aspx">Zip</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Powershell/default.aspx">Powershell</category></item><item><title>C# Code Completion in emacs - getting beanshell equivalent in CSDE</title><link>http://blogs.msdn.com/dotnetinterop/archive/2008/04/21/c-code-completion-in-emacs-more-on-csde-and-beanshell.aspx</link><pubDate>Mon, 21 Apr 2008 19:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8414986</guid><dc:creator>DotNetInterop</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dotnetinterop/comments/8414986.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dotnetinterop/commentrss.aspx?PostID=8414986</wfw:commentRss><description>&lt;P&gt;The beanshell is something that, I think, was specially engineered to support the JDE, and particularly the code completion stuff.&amp;nbsp; In JDEE, emacs starts up a Java VM and runs the beanshell class, in comint (command interpreter) mode.&amp;nbsp; Then emacs can send commands to this beanshell thing, commands like "Tell me what you know about the class named 'foo'". And the beanshell reflects on foo and returns the result, which would include public methods and properties, and so on. &lt;/P&gt;
&lt;P&gt;In my last post i said that the CSDE basically copied all this stuff over and did a search-and-replace (s/java/csharp).&amp;nbsp; That's obviously not gonna work in general, and in particular with the beanshell.&amp;nbsp; But we do have this &lt;A href="http://search.live.com/results.aspx?q=powershell+&amp;amp;form=QBRE"&gt;Powershell&lt;/A&gt; thing in .NET land, don't we?&amp;nbsp; Maybe you've heard of it.&amp;nbsp; And I already put together a working &lt;A class="" href="http://blogs.msdn.com/dotnetinterop/archive/2008/04/10/run-powershell-as-a-shell-within-emacs.aspx" mce_href="http://blogs.msdn.com/dotnetinterop/archive/2008/04/10/run-powershell-as-a-shell-within-emacs.aspx"&gt;powershell comint mode for emacs&lt;/A&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just now I wrote a little TypeInfo class that exposes a single public static method, GetTypeInfo(). It uses reflection to list the members of a named class.&amp;nbsp; I can load that TypeInfo() class into Powershell and interrogate types like this: &lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 2pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 2pt; FONT-SIZE: 9pt; BACKGROUND: white; PADDING-BOTTOM: 2pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 2pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;&lt;PRE&gt;  [System.Reflection.Assembly]::LoadFrom(&lt;SPAN style="COLOR: #bc8f8f"&gt;"c:\\dinoch\\dev\\dotnet\\TypeInfo.dll"&lt;/SPAN&gt;);

  [Ionic.Reflection.Utilities.TypeInfo]::GetTypeInfo(&lt;SPAN style="COLOR: #bc8f8f"&gt;"System.Data.SqlClient.SqlCommand"&lt;/SPAN&gt;,
                                  &lt;SPAN style="COLOR: #bc8f8f"&gt;"System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&lt;/SPAN&gt;);

  [Ionic.Reflection.Utilities.TypeInfo]::GetTypeInfo(&lt;SPAN style="COLOR: #bc8f8f"&gt;"System.Xml.XmlReader"&lt;/SPAN&gt;,
                                  &lt;SPAN style="COLOR: #bc8f8f"&gt;"System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&lt;/SPAN&gt;);

  [Ionic.Reflection.Utilities.TypeInfo]::GetTypeInfo(&lt;SPAN style="COLOR: #bc8f8f"&gt;"System.DateTime"&lt;/SPAN&gt;,
                                  &lt;SPAN style="COLOR: #bc8f8f"&gt;"mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&lt;/SPAN&gt;);
&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;This is pretty much what beanshell does for JDE.&amp;nbsp; Now to figure out how to return the information in the way that CSDE can use it. &lt;/P&gt;
&lt;P mce_keep="true"&gt;I know, I know.&amp;nbsp; I said I didn't want to write a code completion thing for C# in emacs.&amp;nbsp; But the various building blocks are all just sitting there, ready to be stitched together.&amp;nbsp; It's not far off.&amp;nbsp; &lt;/P&gt;
&lt;P style="COLOR: red"&gt;[ Update:&amp;nbsp; for the next installment in this drama, see the &lt;A href="http://blogs.msdn.com/dotnetinterop/archive/2008/04/22/c-code-completion-in-emacs-csde-now-has-a-csdeshell.aspx"&gt;next post&lt;/A&gt;.]&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8414986" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Interop/default.aspx">Interop</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Powershell/default.aspx">Powershell</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/emacs/default.aspx">emacs</category></item><item><title>Powershell script to batch-update AssemblyInfo.cs with new Version</title><link>http://blogs.msdn.com/dotnetinterop/archive/2008/04/21/powershell-script-to-batch-update-assemblyinfo-cs-with-new-version.aspx</link><pubDate>Mon, 21 Apr 2008 18:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8410410</guid><dc:creator>DotNetInterop</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/dotnetinterop/comments/8410410.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dotnetinterop/commentrss.aspx?PostID=8410410</wfw:commentRss><description>&lt;P&gt;I wrote this script to update all the AssemblyInfo.cs files in a Visual Studio solution, to have the same version number. This is the kind of thing I would have used Perl to do, in the past. But Powershell's got this covered nicely. &lt;/P&gt;
&lt;P style="COLOR: maroon"&gt;&lt;EM&gt;[ 23 April 2008 - 1150am PST - I updated the script to deal with the AssemblyInfo.vb files in a VB project, and also to deal with version numbers that have less than 4 digits. Thanks for the suggestion, Jason! ] &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Maybe someone can learn from this. &lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 2pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 2pt; FONT-SIZE: 9pt; BACKGROUND: white; PADDING-BOTTOM: 2pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 2pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #b22222"&gt;# &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;SetVersion.ps1
#
# Set the version in all the AssemblyInfo.cs or AssemblyInfo.vb files in any subdirectory.
#
# usage:  
#  from cmd.exe: 
#     powershell.exe SetVersion.ps1  2.8.3.0
# 
#  from powershell.exe prompt: 
#     .\SetVersion.ps1  2.8.3.0
#
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;# &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;last saved Time-stamp: &amp;lt;Wednesday, April 23, 2008  11:46:40  (by dinoch)&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;#&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;
&lt;/SPAN&gt;

&lt;SPAN style="COLOR: #a020f0"&gt;function&lt;/SPAN&gt; Usage
{
  echo &lt;SPAN style="COLOR: #bc8f8f"&gt;"Usage: "&lt;/SPAN&gt;;
  echo &lt;SPAN style="COLOR: #bc8f8f"&gt;"  from cmd.exe: "&lt;/SPAN&gt;;
  echo &lt;SPAN style="COLOR: #bc8f8f"&gt;"     powershell.exe SetVersion.ps1  2.8.3.0"&lt;/SPAN&gt;;
  echo &lt;SPAN style="COLOR: #bc8f8f"&gt;" "&lt;/SPAN&gt;;
  echo &lt;SPAN style="COLOR: #bc8f8f"&gt;"  from powershell.exe prompt: "&lt;/SPAN&gt;;
  echo &lt;SPAN style="COLOR: #bc8f8f"&gt;"     .\SetVersion.ps1  2.8.3.0"&lt;/SPAN&gt;;
  echo &lt;SPAN style="COLOR: #bc8f8f"&gt;" "&lt;/SPAN&gt;;
}


&lt;SPAN style="COLOR: #a020f0"&gt;function&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Update-SourceVersion&lt;/SPAN&gt;
{
  Param ([string]&lt;SPAN style="COLOR: #b8860b"&gt;$Version&lt;/SPAN&gt;)
  &lt;SPAN style="COLOR: #b8860b"&gt;$NewVersion&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #bc8f8f"&gt;'AssemblyVersion("'&lt;/SPAN&gt; + &lt;SPAN style="COLOR: #b8860b"&gt;$Version&lt;/SPAN&gt; + &lt;SPAN style="COLOR: #bc8f8f"&gt;'")'&lt;/SPAN&gt;;
  &lt;SPAN style="COLOR: #b8860b"&gt;$NewFileVersion&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #bc8f8f"&gt;'AssemblyFileVersion("'&lt;/SPAN&gt; + &lt;SPAN style="COLOR: #b8860b"&gt;$Version&lt;/SPAN&gt; + &lt;SPAN style="COLOR: #bc8f8f"&gt;'")'&lt;/SPAN&gt;;

  &lt;SPAN style="COLOR: #a020f0"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #b8860b"&gt;$o&lt;/SPAN&gt; in &lt;SPAN style="COLOR: #b8860b"&gt;$input&lt;/SPAN&gt;) 
  {
    &lt;SPAN style="COLOR: #0000ff"&gt;Write-output&lt;/SPAN&gt; &lt;SPAN style="COLOR: #b8860b"&gt;$o.FullName&lt;/SPAN&gt;
    &lt;SPAN style="COLOR: #b8860b"&gt;$TmpFile&lt;/SPAN&gt; = &lt;SPAN style="COLOR: #b8860b"&gt;$o.FullName&lt;/SPAN&gt; + &lt;SPAN style="COLOR: #bc8f8f"&gt;".tmp"&lt;/SPAN&gt;

     &lt;SPAN style="COLOR: #0000ff"&gt;get-content&lt;/SPAN&gt; &lt;SPAN style="COLOR: #b8860b"&gt;$o.FullName&lt;/SPAN&gt; | 
        %{&lt;SPAN style="COLOR: #b8860b"&gt;$_&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-replace&lt;/SPAN&gt; &lt;SPAN style="COLOR: #bc8f8f"&gt;'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #b8860b"&gt;$NewVersion&lt;/SPAN&gt; } |
        %{&lt;SPAN style="COLOR: #b8860b"&gt;$_&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-replace&lt;/SPAN&gt; &lt;SPAN style="COLOR: #bc8f8f"&gt;'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #b8860b"&gt;$NewFileVersion&lt;/SPAN&gt; }  &amp;gt; &lt;SPAN style="COLOR: #b8860b"&gt;$TmpFile&lt;/SPAN&gt;

     &lt;SPAN style="COLOR: #0000ff"&gt;move-item&lt;/SPAN&gt; &lt;SPAN style="COLOR: #b8860b"&gt;$TmpFile&lt;/SPAN&gt; &lt;SPAN style="COLOR: #b8860b"&gt;$o.FullName&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-force&lt;/SPAN&gt;
  }
}


&lt;SPAN style="COLOR: #a020f0"&gt;function&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;Update-AllAssemblyInfoFiles&lt;/SPAN&gt; ( &lt;SPAN style="COLOR: #b8860b"&gt;$version&lt;/SPAN&gt; )
{
  &lt;SPAN style="COLOR: #a020f0"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #b8860b"&gt;$file&lt;/SPAN&gt; in &lt;SPAN style="COLOR: #bc8f8f"&gt;"AssemblyInfo.cs"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #bc8f8f"&gt;"AssemblyInfo.vb"&lt;/SPAN&gt; ) 
  {
    &lt;SPAN style="COLOR: #0000ff"&gt;get-childitem&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-recurse&lt;/SPAN&gt; |? {&lt;SPAN style="COLOR: #b8860b"&gt;$_.Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;-eq&lt;/SPAN&gt; &lt;SPAN style="COLOR: #b8860b"&gt;$file&lt;/SPAN&gt;} | &lt;SPAN style="COLOR: #0000ff"&gt;Update-SourceVersion&lt;/SPAN&gt; &lt;SPAN style="COLOR: #b8860b"&gt;$version&lt;/SPAN&gt; ;
  }
}


&lt;SPAN style="COLOR: #b22222"&gt;# &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;validate arguments 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b8860b"&gt;$r&lt;/SPAN&gt;= [System.Text.RegularExpressions.Regex]::Match(&lt;SPAN style="COLOR: #b8860b"&gt;$args&lt;/SPAN&gt;[0], &lt;SPAN style="COLOR: #bc8f8f"&gt;"^[0-9]+(\.[0-9]+){1,3}$"&lt;/SPAN&gt;);

&lt;SPAN style="COLOR: #a020f0"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #b8860b"&gt;$r.Success&lt;/SPAN&gt;)
{
  &lt;SPAN style="COLOR: #0000ff"&gt;Update-AllAssemblyInfoFiles&lt;/SPAN&gt; &lt;SPAN style="COLOR: #b8860b"&gt;$args&lt;/SPAN&gt;[0];
}
&lt;SPAN style="COLOR: #a020f0"&gt;else&lt;/SPAN&gt;
{
  echo &lt;SPAN style="COLOR: #bc8f8f"&gt;" "&lt;/SPAN&gt;;
  echo &lt;SPAN style="COLOR: #bc8f8f"&gt;"Bad Input!"&lt;/SPAN&gt;
  echo &lt;SPAN style="COLOR: #bc8f8f"&gt;" "&lt;/SPAN&gt;;
  Usage ;
}
&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8410410" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/dotnetinterop/attachment/8410410.ashx" length="1627" type="application/octet-stream" /><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Not+Really+Interop/default.aspx">Not Really Interop</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Powershell/default.aspx">Powershell</category></item><item><title>WPF invokes Powershell.exe as an inferior shell</title><link>http://blogs.msdn.com/dotnetinterop/archive/2008/04/11/wpf-invokes-powershell-exe-as-an-inferior-shell.aspx</link><pubDate>Fri, 11 Apr 2008 18:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8376424</guid><dc:creator>DotNetInterop</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dotnetinterop/comments/8376424.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dotnetinterop/commentrss.aspx?PostID=8376424</wfw:commentRss><description>&lt;P&gt;I wrote this up as an example of how to run powershell.exe as an inferior shell from within a WPF app. &lt;/P&gt;
&lt;P&gt;It is not a "Powershell host" in the normal sense of the word, with a &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.management.automation.runspaces.runspace(VS.85).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.management.automation.runspaces.runspace(VS.85).aspx"&gt;RunSpace&lt;/A&gt; and a &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.management.automation.runspaces.runspacefactory.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.management.automation.runspaces.runspacefactory.aspx"&gt;RunSpaceFactory&lt;/A&gt; and so on.&amp;nbsp; Instead, this example uses &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.aspx"&gt;System.Diagnostics.Process&lt;/A&gt; to start powershell.exe as a process, and redirect stdin, stdout, and stderr.&amp;nbsp; The result of those things is displayed in a WPF &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textblock.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textblock.aspx"&gt;TextBlock&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;The key bit is the Shell class, which I show here.&amp;nbsp; It includes async i/o for the output.&amp;nbsp; &lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;\red0\green128\blue0;}??\fs20 \cf1 using\cf0  System;\par ??\cf1 using\cf0  System.Collections.Generic;\par ??\cf1 using\cf0  System.Linq;\par ??\cf1 using\cf0  System.Text;\par ??\par ??\cf1 namespace\cf0  WPF_Host_for_PowerShell\par ??\{\par ??    \cf1 class\cf0  \cf4 Shell\par ??\cf0     \{\par ??        \cf1 public\cf0  \cf1 delegate\cf0  \cf1 void\cf0  \cf4 OutputReceived\cf0 (\cf4 String\cf0  output);\par ??\par ??        \cf1 private\cf0  System.Diagnostics.\cf4 Process\cf0  _p;\par ??        \cf1 private\cf0  System.\cf4 AsyncCallback\cf0  _rc = \cf1 null\cf0 ;\par ??        \cf1 private\cf0  System.IO.\cf4 StreamWriter\cf0  _sw;\par ??\par ??        \cf1 public\cf0  System.IO.\cf4 StreamWriter\cf0  Input \{ \cf1 get\cf0  \{ \cf1 return\cf0  _sw; \} \}\par ??        \cf1 public\cf0  \cf4 OutputReceived\cf0  StdoutOutputReceived \{ \cf1 get\cf0 ; \cf1 set\cf0 ; \}\par ??        \cf1 public\cf0  \cf4 OutputReceived\cf0  StderrOutputReceived \{ \cf1 get\cf0 ; \cf1 set\cf0 ; \}\par ??\par ??        \cf1 public\cf0  Shell(\cf4 String\cf0  exe, \cf1 string\cf0  args, \cf4 OutputReceived\cf0  callback1, \cf4 OutputReceived\cf0  callback2)\par ??        \{\par ??            _rc = \cf1 new\cf0  System.\cf4 AsyncCallback\cf0 (ReadCompleted);\par ??            StdoutOutputReceived = callback1;\par ??            StderrOutputReceived = callback2;\par ??            Launch(exe, args);\par ??        \}\par ??\par ??\par ??        \cf1 public\cf0  \cf1 class\cf0  \cf4 StreamState\par ??\cf0         \{\par ??            \cf1 public\cf0  System.IO.\cf4 Stream\cf0  Stream;\par ??            \cf1 public\cf0  \cf1 byte\cf0 [] Buffer;\par ??            \cf1 public\cf0  \cf4 OutputReceived\cf0  Callback;\par ??\par ??            \cf1 public\cf0  \cf1 const\cf0  \cf1 int\cf0  DefaultBufferSize = 2048;\par ??\par ??            \cf1 public\cf0  StreamState(System.IO.\cf4 Stream\cf0  stream, \cf4 OutputReceived\cf0  callback)\par ??            \{\par ??                Buffer = \cf1 new\cf0  \cf1 byte\cf0 [DefaultBufferSize];\par ??                Stream = stream;\par ??                Callback = callback;\par ??            \}\par ??        \}\par ??\par ??\par ??        \cf1 private\cf0  \cf1 void\cf0  ReadCompleted(System.\cf4 IAsyncResult\cf0  asyncResult)\par ??        \{\par ??            \cf4 StreamState\cf0  state = (\cf4 StreamState\cf0 )asyncResult.AsyncState;\par ??            \cf1 int\cf0  BytesRead = state.Stream.EndRead(asyncResult);\par ??            \cf1 if\cf0  (BytesRead &amp;gt; 0)\par ??            \{\par ??                \cf1 if\cf0  (state.Callback != \cf1 null\cf0 )\par ??                    state.Callback(System.Text.\cf4 Encoding\cf0 .ASCII.GetString(state.Buffer, 0, BytesRead));\par ??\par ??                System.Threading.\cf4 Thread\cf0 .Sleep(20);\par ??                \cf5 // repeat: \par ??\cf0                 state.Stream.BeginRead(state.Buffer,\par ??                    0,\par ??                    state.Buffer.Length,\par ??                    _rc,\par ??                    state);\par ??            \}\par ??\par ??        \}\par ??\par ??\par ??\par ??        \cf1 private\cf0  \cf1 void\cf0  KickoffAsyncReading(System.IO.\cf4 Stream\cf0  stream, \cf4 OutputReceived\cf0  callback)\par ??        \{\par ??            \cf5 // initialize the state for this async read loop: \par ??\cf0             \cf4 StreamState\cf0  state = \cf1 new\cf0  \cf4 StreamState\cf0 (stream, callback);\par ??            System.Threading.\cf4 Thread\cf0 .Sleep(20);\par ??            stream.BeginRead(state.Buffer,  \cf5 // where to put the results\par ??\cf0                 0,                          \cf5 // offset\par ??\cf0                 state.Buffer.Length,        \cf5 // how many bytes (BUFFER_SIZE)\par ??\cf0                 _rc,                        \cf5 // ReadCompleted call back delegate\par ??\cf0                 state);                     \cf5 // local state object\par ??\cf0         \}\par ??\par ??\par ??        \cf1 private\cf0  \cf1 void\cf0  Launch(\cf1 string\cf0  shellexe, \cf1 string\cf0  args)\par ??        \{\par ??            _p = \cf1 new\cf0  System.Diagnostics.\cf4 Process\cf0 ();\par ??            _p.StartInfo.FileName = shellexe;\par ??            _p.StartInfo.Arguments = args;\par ??            _p.StartInfo.WindowStyle = System.Diagnostics.\cf4 ProcessWindowStyle\cf0 .Hidden;\par ??            _p.StartInfo.CreateNoWindow = \cf1 true\cf0 ;\par ??\par ??            _p.StartInfo.RedirectStandardOutput = \cf1 true\cf0 ;\par ??            _p.StartInfo.RedirectStandardError = \cf1 true\cf0 ;\par ??            _p.StartInfo.RedirectStandardInput = \cf1 true\cf0 ;\par ??            _p.StartInfo.UseShellExecute = \cf1 false\cf0 ;  \cf5 // required for redirect\par ??\par ??\cf0             _p.Start();\par ??\par ??            _sw = _p.StandardInput;\par ??            KickoffAsyncReading(_p.StandardOutput.BaseStream, StdoutOutputReceived);\par ??            KickoffAsyncReading(_p.StandardError.BaseStream, StderrOutputReceived);\par ??        \}\par ??\par ??\par ??        \cf1 public\cf0  \cf1 void\cf0  Stop()\par ??        \{\par ??            \cf1 try\par ??\cf0             \{\par ??                _p.Kill();\par ??            \}\par ??            \cf1 catch\cf0  \{ \}\par ??        \}\par ??    \}\par ??\}\par ??}
--&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 2pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 2pt; FONT-SIZE: 9pt; PADDING-BOTTOM: 2pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 2pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Collections.Generic;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Linq;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Text;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;namespace&lt;/SPAN&gt; WPF_Host_for_PowerShell&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/SPAN&gt;&amp;nbsp;{&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Shell&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;delegate&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;OutputReceived&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #2b91af"&gt;String&lt;/SPAN&gt; output);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; System.Diagnostics.&lt;SPAN style="COLOR: #2b91af"&gt;Process&lt;/SPAN&gt; _p;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; System.&lt;SPAN style="COLOR: #2b91af"&gt;AsyncCallback&lt;/SPAN&gt; _rc = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; System.IO.&lt;SPAN style="COLOR: #2b91af"&gt;StreamWriter&lt;/SPAN&gt; _sw;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; System.IO.&lt;SPAN style="COLOR: #2b91af"&gt;StreamWriter&lt;/SPAN&gt; Input { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt; { &lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; _sw; } }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;OutputReceived&lt;/SPAN&gt; StdoutOutputReceived { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;OutputReceived&lt;/SPAN&gt; StderrOutputReceived { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; &lt;SPAN style="COLOR: blue"&gt;set&lt;/SPAN&gt;; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; Shell(&lt;SPAN style="COLOR: #2b91af"&gt;String&lt;/SPAN&gt; exe, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; args, &lt;SPAN style="COLOR: #2b91af"&gt;OutputReceived&lt;/SPAN&gt; callback1, &lt;SPAN style="COLOR: #2b91af"&gt;OutputReceived&lt;/SPAN&gt; callback2)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _rc = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; System.&lt;SPAN style="COLOR: #2b91af"&gt;AsyncCallback&lt;/SPAN&gt;(ReadCompleted);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; StdoutOutputReceived = callback1;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;24&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; StderrOutputReceived = callback2;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;25&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Launch(exe, args);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;26&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;27&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;28&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;29&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;StreamState&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;31&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; System.IO.&lt;SPAN style="COLOR: #2b91af"&gt;Stream&lt;/SPAN&gt; Stream;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;32&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;byte&lt;/SPAN&gt;[] Buffer;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;33&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;OutputReceived&lt;/SPAN&gt; Callback;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;34&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;35&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; DefaultBufferSize = 2048;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;36&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;37&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; StreamState(System.IO.&lt;SPAN style="COLOR: #2b91af"&gt;Stream&lt;/SPAN&gt; stream, &lt;SPAN style="COLOR: #2b91af"&gt;OutputReceived&lt;/SPAN&gt; callback)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;38&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;39&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Buffer = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;byte&lt;/SPAN&gt;[DefaultBufferSize];&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;40&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Stream = stream;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;41&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Callback = callback;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;42&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;43&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;44&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;45&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;46&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; ReadCompleted(System.&lt;SPAN style="COLOR: #2b91af"&gt;IAsyncResult&lt;/SPAN&gt; asyncResult)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;47&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;48&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;StreamState&lt;/SPAN&gt; state = (&lt;SPAN style="COLOR: #2b91af"&gt;StreamState&lt;/SPAN&gt;)asyncResult.AsyncState;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;49&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; BytesRead = state.Stream.EndRead(asyncResult);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;50&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (BytesRead &amp;gt; 0)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;51&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;52&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (state.Callback != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;53&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; state.Callback(System.Text.&lt;SPAN style="COLOR: #2b91af"&gt;Encoding&lt;/SPAN&gt;.ASCII.GetString(state.Buffer, 0, BytesRead));&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;54&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;55&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.Threading.&lt;SPAN style="COLOR: #2b91af"&gt;Thread&lt;/SPAN&gt;.Sleep(20);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;56&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// repeat: &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;57&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; state.Stream.BeginRead(state.Buffer,&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;58&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;59&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; state.Buffer.Length,&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;60&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _rc,&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;61&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; state);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;62&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;63&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;64&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;65&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;66&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;67&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;68&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; KickoffAsyncReading(System.IO.&lt;SPAN style="COLOR: #2b91af"&gt;Stream&lt;/SPAN&gt; stream, &lt;SPAN style="COLOR: #2b91af"&gt;OutputReceived&lt;/SPAN&gt; callback)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;69&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;70&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// initialize the state for this async read loop: &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;71&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;StreamState&lt;/SPAN&gt; state = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;StreamState&lt;/SPAN&gt;(stream, callback);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;72&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.Threading.&lt;SPAN style="COLOR: #2b91af"&gt;Thread&lt;/SPAN&gt;.Sleep(20);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;73&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; stream.BeginRead(state.Buffer,&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// where to put the results&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;74&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// offset&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;75&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; state.Buffer.Length,&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// how many bytes (BUFFER_SIZE)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;76&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _rc,&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// ReadCompleted call back delegate&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;77&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; state);&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// local state object&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;78&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;79&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;80&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;81&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Launch(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; shellexe, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; args)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;82&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;83&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _p = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; System.Diagnostics.&lt;SPAN style="COLOR: #2b91af"&gt;Process&lt;/SPAN&gt;();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;84&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _p.StartInfo.FileName = shellexe;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;85&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _p.StartInfo.Arguments = args;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;86&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _p.StartInfo.WindowStyle = System.Diagnostics.&lt;SPAN style="COLOR: #2b91af"&gt;ProcessWindowStyle&lt;/SPAN&gt;.Hidden;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;87&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _p.StartInfo.CreateNoWindow = &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;88&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;89&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _p.StartInfo.RedirectStandardOutput = &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;90&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _p.StartInfo.RedirectStandardError = &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;91&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _p.StartInfo.RedirectStandardInput = &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;92&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _p.StartInfo.UseShellExecute = &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// required for redirect&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;93&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;94&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _p.Start();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;95&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;96&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _sw = _p.StandardInput;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;97&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; KickoffAsyncReading(_p.StandardOutput.BaseStream, StdoutOutputReceived);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;98&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; KickoffAsyncReading(_p.StandardError.BaseStream, StderrOutputReceived);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;99&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;100&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;101&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;102&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Stop()&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;103&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;104&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;try&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;105&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;106&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; _p.Kill();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;107&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;108&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;catch&lt;/SPAN&gt; { }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;109&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;110&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;111&lt;/SPAN&gt;&amp;nbsp;}&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;To use it, it looks something like this: &lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red128\green128\blue128;\red0\green128\blue0;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf1 using\cf0  System;\par ??\cf1 using\cf0  System.Collections.Generic;\par ??\cf1 using\cf0  System.Linq;\par ??\cf1 using\cf0  System.Text;\par ??\cf1 using\cf0  System.Windows;\par ??\cf1 using\cf0  System.Windows.Controls;\par ??\cf1 using\cf0  System.Windows.Data;\par ??\cf1 using\cf0  System.Windows.Documents;\par ??\cf1 using\cf0  System.Windows.Input;\par ??\cf1 using\cf0  System.Windows.Media;\par ??\cf1 using\cf0  System.Windows.Media.Imaging;\par ??\cf1 using\cf0  System.Windows.Navigation;\par ??\cf1 using\cf0  System.Windows.Shapes;\par ??\par ??\cf1 namespace\cf0  WPF_Host_for_PowerShell\par ??\{\par ??    \cf4 ///\cf5  \cf4 &amp;lt;summary&amp;gt;\par ??\cf0     \cf4 ///\cf5  Interaction logic for Window1.xaml\par ??\cf0     \cf4 ///\cf5  \cf4 &amp;lt;/summary&amp;gt;\par ??\cf0     \cf1 public\cf0  \cf1 partial\cf0  \cf1 class\cf0  \cf6 Window1\cf0  : \cf6 Window\par ??\cf0     \{\par ??        \cf1 delegate\cf0  \cf1 void\cf0  \cf6 MyAppendCallback\cf0 (\cf1 string\cf0  s, System.Windows.Media.\cf6 Brush\cf0  color);\par ??\par ??        \cf6 Shell\cf0  shell;\par ??        \cf6 TextBlock\cf0  currentTextBlock= \cf1 null\cf0 ;\par ??        \cf6 MyAppendCallback\cf0  AppendDelegate = \cf1 null\cf0 ;\par ??\par ??        \cf1 public\cf0  Window1()\par ??        \{\par ??            InitializeComponent();\par ??\par ??            AppendDelegate= \cf1 new\cf0  \cf6 MyAppendCallback\cf0 (MyAppend);\par ??        \}\par ??\par ??        \cf1 private\cf0  \cf1 void\cf0  MyAppend(\cf1 string\cf0  s, System.Windows.Media.\cf6 Brush\cf0  color)\par ??        \{\par ??            \cf1 if\cf0  (\cf1 this\cf0 .Scroller1.Dispatcher.Thread != System.Threading.\cf6 Thread\cf0 .CurrentThread)\par ??            \{\par ??                \cf1 this\cf0 .Dispatcher.BeginInvoke\par ??                    (System.Windows.Threading.\cf6 DispatcherPriority\cf0 .Normal, AppendDelegate, s, \cf1 new\cf0  \cf1 object\cf0 [] \{ color \});\par ??                \cf1 return\cf0 ;\par ??            \}\par ??\par ??            \cf1 lock\cf0  (\cf1 this\cf0 .Scroller1)\par ??            \{\par ??                \cf1 if\cf0  (s != \cf7 ""\cf0 )\par ??                    \cf1 this\cf0 .currentTextBlock.Inlines.Add(\cf1 new\cf0  \cf6 Run\cf0 () \{ Text = s, Foreground = color \});\par ??\par ??                \cf1 this\cf0 .Scroller1.ScrollToBottom();\par ??            \}\par ??        \}\par ??\par ??        \cf1 void\cf0  StdoutReceived(\cf1 string\cf0  t)\par ??        \{\par ??            MyAppend(t, System.Windows.Media.\cf6 Brushes\cf0 .BlueViolet);\par ??        \}\par ??\par ??        \cf1 void\cf0  StderrReceived(\cf1 string\cf0  t)\par ??        \{\par ??            MyAppend(t, System.Windows.Media.\cf6 Brushes\cf0 .Red);\par ??        \}\par ??\par ??\par ??        \cf1 private\cf0  \cf1 void\cf0  Window_Loaded(\cf1 object\cf0  sender, \cf6 RoutedEventArgs\cf0  e)\par ??        \{\par ??            \cf5 // creating the shell starts it up\par ??\cf0             shell = \cf1 new\cf0  \cf6 Powershell\cf0 (\par ??                \cf1 new\cf0  \cf6 Shell\cf0 .\cf6 OutputReceived\cf0 (StdoutReceived),\par ??                \cf1 new\cf0  \cf6 Shell\cf0 .\cf6 OutputReceived\cf0 (StderrReceived));\par ??\par ??            InitCommand();\par ??\par ??            shell.Input.WriteLine(\cf7 "prompt"\cf0 );\par ??            shell.Input.Flush();\par ??        \}\par ??\par ??        \cf1 private\cf0  \cf1 void\cf0  InitCommand()\par ??        \{\par ??            \cf5 // add a new textblock for each command\par ??\cf0             currentTextBlock = \cf1 new\cf0  \cf6 TextBlock\cf0 ();\par ??            currentTextBlock.FontFamily = \cf1 new\cf0  \cf6 FontFamily\cf0 (\cf7 "Consolas"\cf0 );\par ??            currentTextBlock.Margin = \cf1 new\cf0  \cf6 Thickness\cf0 (0d);\par ??            \cf5 //currentTextBlock.Foreground = color;\par ??\cf0             \cf1 this\cf0 .OutputPanel.Children.Add(currentTextBlock);\par ??        \}\par ??\par ??        \cf1 private\cf0  \cf1 void\cf0  Button_Click(\cf1 object\cf0  sender, \cf6 RoutedEventArgs\cf0  e)\par ??        \{\par ??            InitCommand();\par ??\par ??            MyAppend(\cf1 this\cf0 .textBox1.Text, System.Windows.Media.\cf6 Brushes\cf0 .SteelBlue);\par ??            shell.Input.WriteLine(\cf1 this\cf0 .textBox1.Text);\par ??\par ??            shell.Input.WriteLine(\cf7 "prompt"\cf0 );\par ??            shell.Input.Flush();\par ??        \}\par ??\par ??        \cf1 private\cf0  \cf1 void\cf0  Window_Closing(\cf1 object\cf0  sender, System.ComponentModel.\cf6 CancelEventArgs\cf0  e)\par ??        \{\par ??            shell.Stop();\par ??        \}\par ??    \}\par ??\}\par ??}
--&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 2pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 2pt; FONT-SIZE: 9pt; PADDING-BOTTOM: 2pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 2pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Collections.Generic;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Linq;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Text;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Windows;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Windows.Controls;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Windows.Data;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Windows.Documents;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Windows.Input;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Windows.Media;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Windows.Media.Imaging;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Windows.Navigation;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; System.Windows.Shapes;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;namespace&lt;/SPAN&gt; WPF_Host_for_PowerShell&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/SPAN&gt;&amp;nbsp;{&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; Interaction logic for Window1.xaml&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: gray"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;partial&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Window1&lt;/SPAN&gt; : &lt;SPAN style="COLOR: #2b91af"&gt;Window&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;delegate&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyAppendCallback&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; s, System.Windows.Media.&lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt; color);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;24&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Shell&lt;/SPAN&gt; shell;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;25&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;TextBlock&lt;/SPAN&gt; currentTextBlock= &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;26&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;MyAppendCallback&lt;/SPAN&gt; AppendDelegate = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;27&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;28&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; Window1()&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;29&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;31&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;32&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; AppendDelegate= &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyAppendCallback&lt;/SPAN&gt;(MyAppend);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;33&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;34&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;35&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; MyAppend(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; s, System.Windows.Media.&lt;SPAN style="COLOR: #2b91af"&gt;Brush&lt;/SPAN&gt; color)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;36&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;37&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.Scroller1.Dispatcher.Thread != System.Threading.&lt;SPAN style="COLOR: #2b91af"&gt;Thread&lt;/SPAN&gt;.CurrentThread)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;38&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;39&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.Dispatcher.BeginInvoke&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;40&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (System.Windows.Threading.&lt;SPAN style="COLOR: #2b91af"&gt;DispatcherPriority&lt;/SPAN&gt;.Normal, AppendDelegate, s, &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt;[] { color });&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;41&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;42&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;43&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;44&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;lock&lt;/SPAN&gt; (&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.Scroller1)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;45&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;46&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (s != &lt;SPAN style="COLOR: #a31515"&gt;""&lt;/SPAN&gt;)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;47&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.currentTextBlock.Inlines.Add(&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Run&lt;/SPAN&gt;() { Text = s, Foreground = color });&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;48&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;49&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.Scroller1.ScrollToBottom();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;50&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;51&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;52&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;53&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; StdoutReceived(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; t)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;54&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;55&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; MyAppend(t, System.Windows.Media.&lt;SPAN style="COLOR: #2b91af"&gt;Brushes&lt;/SPAN&gt;.BlueViolet);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;56&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;57&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;58&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; StderrReceived(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; t)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;59&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;60&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; MyAppend(t, System.Windows.Media.&lt;SPAN style="COLOR: #2b91af"&gt;Brushes&lt;/SPAN&gt;.Red);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;61&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;62&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;63&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;64&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Window_Loaded(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;65&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;66&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// creating the shell starts it up&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;67&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; shell = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Powershell&lt;/SPAN&gt;(&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;68&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Shell&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #2b91af"&gt;OutputReceived&lt;/SPAN&gt;(StdoutReceived),&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;69&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Shell&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #2b91af"&gt;OutputReceived&lt;/SPAN&gt;(StderrReceived));&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;70&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;71&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; InitCommand();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;72&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;73&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; shell.Input.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"prompt"&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;74&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; shell.Input.Flush();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;75&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;76&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;77&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; InitCommand()&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;78&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;79&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// add a new textblock for each command&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;80&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentTextBlock = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;TextBlock&lt;/SPAN&gt;();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;81&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentTextBlock.FontFamily = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;FontFamily&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"Consolas"&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;82&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; currentTextBlock.Margin = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Thickness&lt;/SPAN&gt;(0d);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;83&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;//currentTextBlock.Foreground = color;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;84&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.OutputPanel.Children.Add(currentTextBlock);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;85&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;86&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;87&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Button_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;RoutedEventArgs&lt;/SPAN&gt; e)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;88&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;89&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; InitCommand();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;90&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;91&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; MyAppend(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.textBox1.Text, System.Windows.Media.&lt;SPAN style="COLOR: #2b91af"&gt;Brushes&lt;/SPAN&gt;.SteelBlue);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;92&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; shell.Input.WriteLine(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;.textBox1.Text);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;93&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;94&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; shell.Input.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"prompt"&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;95&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; shell.Input.Flush();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;96&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;97&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;98&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Window_Closing(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, System.ComponentModel.&lt;SPAN style="COLOR: #2b91af"&gt;CancelEventArgs&lt;/SPAN&gt; e)&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;99&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;100&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; shell.Stop();&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;101&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;102&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;103&lt;/SPAN&gt;&amp;nbsp;}&lt;/P&gt;&lt;/DIV&gt;
&lt;P&gt;The full source is attached. Maybe interesting and re-usable&amp;nbsp;for someone who wants to embed Powershell capability into an application. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8376424" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/dotnetinterop/attachment/8376424.ashx" length="17164" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Not+Really+Interop/default.aspx">Not Really Interop</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Powershell/default.aspx">Powershell</category></item><item><title>PowerShell in Emacs, proof!</title><link>http://blogs.msdn.com/dotnetinterop/archive/2008/04/10/powershell-in-emacs-proof.aspx</link><pubDate>Fri, 11 Apr 2008 07:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8378376</guid><dc:creator>DotNetInterop</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/dotnetinterop/comments/8378376.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dotnetinterop/commentrss.aspx?PostID=8378376</wfw:commentRss><description>&lt;P&gt;Here's the proof that &lt;EM&gt;you&lt;/EM&gt; &lt;EM&gt;can &lt;A class="" href="http://blogs.msdn.com/dotnetinterop/archive/2008/04/10/run-powershell-as-a-shell-within-emacs.aspx" mce_href="http://blogs.msdn.com/dotnetinterop/archive/2008/04/10/run-powershell-as-a-shell-within-emacs.aspx"&gt;run powershell as a shell in Emacs&lt;/A&gt;&lt;/EM&gt;. &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://blogs.msdn.com/blogfiles/dotnetinterop/041108_0450_PowerShelli1.png" mce_src="http://blogs.msdn.com/blogfiles/dotnetinterop/041108_0450_PowerShelli1.png"&gt; &lt;/P&gt;
&lt;P&gt;Grab the download from &lt;A href="http://blogs.msdn.com/dotnetinterop/archive/2008/04/10/run-powershell-as-a-shell-within-emacs.aspx" mce_href="http://blogs.msdn.com/dotnetinterop/archive/2008/04/10/run-powershell-as-a-shell-within-emacs.aspx"&gt;yesterday&lt;/A&gt; to get this awesome power yourself! &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8378376" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Interop/default.aspx">Interop</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Powershell/default.aspx">Powershell</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/emacs/default.aspx">emacs</category></item><item><title>Run PowerShell as a shell within Emacs</title><link>http://blogs.msdn.com/dotnetinterop/archive/2008/04/10/run-powershell-as-a-shell-within-emacs.aspx</link><pubDate>Thu, 10 Apr 2008 22:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8376018</guid><dc:creator>DotNetInterop</dc:creator><slash:comments>12</slash:comments><comments>http://blogs.msdn.com/dotnetinterop/comments/8376018.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dotnetinterop/commentrss.aspx?PostID=8376018</wfw:commentRss><description>&lt;P&gt;I saw a couple people asking about running powershell as an inferior shell within emacs.&amp;nbsp; Here's what I do. &lt;/P&gt;
&lt;P&gt;For the tragically unhip, some background:&amp;nbsp;&lt;A class="" href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" mce_href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx"&gt;PowerShell&lt;/A&gt; is a nifty shell, it ships as an add-on to Windows.&amp;nbsp; Currently at v1.0, but the &lt;A class="" href="http://www.microsoft.com/downloads/results.aspx?pocId=&amp;amp;freetext=powershell&amp;amp;DisplayLang=en#" mce_href="http://www.microsoft.com/downloads/results.aspx?pocId=&amp;amp;freetext=powershell&amp;amp;DisplayLang=en#"&gt;v2.0 is available as a CTP&lt;/A&gt;.&amp;nbsp; Emacs is the venerable supereditor that does 1001 things - one of those things is the ability to &lt;A class="" href="http://moxie.oswego.edu/doc/emacs/Shell.html#Shell" mce_href="http://moxie.oswego.edu/doc/emacs/Shell.html#Shell"&gt;run a shell&lt;/A&gt; within a buffer.&amp;nbsp; Emacs runs on Unix and Windows, and the shell stuff is configurable across a wide variety of shells and operating systems.&amp;nbsp; As I was saying, some people have expressed interest in running PowerShell as an inferior shell within Emacs. &lt;/P&gt;
&lt;P&gt;&lt;EM&gt;We're not talking about a powershell script editing mode.&lt;/EM&gt; &lt;A class="" href="http://www.viveksharma.com/techlog/attache/powershell-mode.el.txt" mce_href="http://www.viveksharma.com/techlog/attache/powershell-mode.el.txt"&gt;That problem has been solved&lt;/A&gt;. Instead, we're talking about running a powershell interactively within emacs.&lt;/P&gt;
&lt;P&gt;There are a couple challenges with doing this.&amp;nbsp; First, emacs is complex, and it is hard for people to figure out to do what they want.&amp;nbsp;&amp;nbsp;Even the doc is impenetrable.&amp;nbsp; Basically you just have to KNOW how to do something, or someone else shows you.&amp;nbsp; Getting back to our situation, to explicitly specify the shell to run, in emacs you set a variable called &lt;STRONG&gt;explicit-shell-file-name&lt;/STRONG&gt;.&amp;nbsp;Great, so we set this to c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe. There's an example for starting shells that says "to set the arguments to the shell, set the &lt;STRONG&gt;explicit-sh-args &lt;/STRONG&gt;variable. People were setting this variable and trying to run PowerShell but &lt;A class="" href="http://search.msn.com/results.aspx?q=explicit-sh-args+powershell&amp;amp;FORM=QBHP" mce_href="http://search.msn.com/results.aspx?q=explicit-sh-args+powershell&amp;amp;FORM=QBHP"&gt;getting an error&lt;/A&gt;.&amp;nbsp;That's because the variable name for arguments is different for each shell.&amp;nbsp; For bash, sh is the image and the variable is explicit-sh-args.&amp;nbsp; For powershell, the variable to set is &lt;STRONG&gt;explicit-powershell.exe-args &lt;/STRONG&gt;.&amp;nbsp;Of course!&amp;nbsp; This isn't explicitly documented anywhere (that I could see), but if you read the source code for shell.el you will see it. And, to further complicate things, if you don't explicitly set anything in that args variable, shell.el &lt;EM&gt;implicitly &lt;/EM&gt;includes -i as an argument, which makes powershell barf.&amp;nbsp; -i is a valid powershell argument, but it needs another param.&amp;nbsp; Hence the barf.&amp;nbsp; Anyway, to avoid all this, set &lt;STRONG&gt;explicit-powershell.exe-args .&amp;nbsp; &lt;/STRONG&gt;Example:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: 1px; BORDER-TOP: 1px; BORDER-LEFT: 1px; BORDER-BOTTOM: 1px"&gt;&lt;PRE&gt;  (setq explicit-shell-file-name "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe")
  (setq explicit-powershell.exe-args '("-Command" "-" )) ; interactive, but no command prompt &lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;After setting these variables, to launch powershell from within emacs, just use &lt;STRONG&gt;M-x shell&lt;/STRONG&gt;.&amp;nbsp;This gets you to the second problem: powershell goes into "noninteractive mode".&amp;nbsp; It emits no prompts, although it reads from the stdin and puts output on stdout.&amp;nbsp; So you can see the input and output, but no prompts at all.&amp;nbsp; Needless to say, it's a bit unfriendly to do this. &lt;/P&gt;
&lt;P&gt;To fix this up we have to ask powershell to give us prompts.&amp;nbsp; A simple thing to do would be to launch powershell in interactive mode, despite the fact that stdin and stdout have been redirected.&amp;nbsp; There's an option on powershell.exe to launch it in "noninteractive mode" which means no prompts, and which is already what we have.&amp;nbsp; We want the converse.&amp;nbsp; I couldn't figure a way to do the "force interactive mode", so I used some emacs lisp to sort of fake it. &lt;/P&gt;
&lt;P&gt;Within shell mode, there are "hooks" that emacs will call, on certain events, and overrides that you can set. (Sort of like the channel stack in WCF.)&amp;nbsp; One possible override is the "send command to shell" method.&amp;nbsp;You can write some custom code that runs, every time the user types in a command to the shell, in order to&amp;nbsp;send the command to the shell.&amp;nbsp;You can filter it, modify it, log it, suppress it, whatever.&amp;nbsp; I wrote a simple wrapper in elisp that sends the original command, and then ALSO sends the "prompt" command.&amp;nbsp; This causes powershell to emit the prompt, after the first, explicit command is run.&amp;nbsp; Cool.&amp;nbsp; That's what we want. &lt;/P&gt;
&lt;P&gt;Then there are some rough edges. For example, powershell assumes an 80-character width for a terminal in non-interactive mode.&amp;nbsp; You can set this by tickling the &lt;A class="" href="http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/console.mspx" mce_href="http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/console.mspx"&gt;RawUI&lt;/A&gt; object within powershell itself.&amp;nbsp; This is made possible with another hook.&amp;nbsp; Also, I need to resize the powershell terminal whenever the emacs window changes.&amp;nbsp; So I need to hook the window-size-change event within emacs. &lt;/P&gt;
&lt;P&gt;One last thing is that the powershell prompt comes out with a trailing newline.&amp;nbsp; So I need to trim that off as well, so that the next command you type in the powershell inferior shell, is just to the right of the powershell prompt. &lt;/P&gt;
&lt;P&gt;Anyway, the result is the brief bit of elisp attached here. It's pretty bare-bones, but it's a start.&amp;nbsp; And it lets you do what you want - run powershell as an inferior shell within emacs.&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 2pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 2pt; FONT-SIZE: 9pt; BACKGROUND: white; PADDING-BOTTOM: 2pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 2pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: #b22222"&gt;;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;powershell.el, version 0.1
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;Author: Dino Chiesa
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;Thu, 10 Apr 2008  11:10
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;Run Windows PowerShell v1.0 as an inferior shell within emacs. Tested with emacs v22.2.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;TODO:
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;;  &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;test what happens when you expand the window size beyond the maxWindowWidth for the RawUI
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;;  &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;make everything configurable (Powershell exe, initial args, powershell prompt regexp)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;;  &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;implement powershell launch hooks
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;;  &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;prevent backspace from deleting the powershell prompt? (do other shells do this?)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;
&lt;/SPAN&gt;
(&lt;SPAN style="COLOR: #a020f0"&gt;require&lt;/SPAN&gt; '&lt;SPAN style="COLOR: #5f9ea0"&gt;shell&lt;/SPAN&gt;)


(&lt;SPAN style="COLOR: #a020f0"&gt;defun&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;powershell-gen-window-width-string&lt;/SPAN&gt; ()
  (concat  &lt;SPAN style="COLOR: #bc8f8f"&gt;"$a = (Get-Host).UI.RawUI\n"&lt;/SPAN&gt; 
            &lt;SPAN style="COLOR: #bc8f8f"&gt;"$b = $a.WindowSize\n"&lt;/SPAN&gt;
            &lt;SPAN style="COLOR: #bc8f8f"&gt;"$b.Width = "&lt;/SPAN&gt; (number-to-string  (window-width)) &lt;SPAN style="COLOR: #bc8f8f"&gt;"\n"&lt;/SPAN&gt;
            &lt;SPAN style="COLOR: #bc8f8f"&gt;"$a.BufferSize = $b\n"&lt;/SPAN&gt;
            &lt;SPAN style="COLOR: #bc8f8f"&gt;"$a.WindowSize = $b"&lt;/SPAN&gt;)
  )
  

(&lt;SPAN style="COLOR: #a020f0"&gt;defvar&lt;/SPAN&gt; &lt;SPAN style="COLOR: #b8860b"&gt;powershell-prompt-pattern&lt;/SPAN&gt;  &lt;SPAN style="COLOR: #bc8f8f"&gt;"PS [&lt;/SPAN&gt;&lt;SPAN style="COLOR: #bc8f8f"&gt;^&lt;/SPAN&gt;&lt;SPAN style="COLOR: #bc8f8f"&gt;#$%&amp;gt;]+&amp;gt;"&lt;/SPAN&gt; 
  &lt;SPAN style="COLOR: #bc8f8f"&gt;"Regexp for powershell prompt.  This isn't really used, because I couldn't figure out how to get it to work."&lt;/SPAN&gt;
  )

(&lt;SPAN style="COLOR: #a020f0"&gt;defgroup&lt;/SPAN&gt; &lt;SPAN style="COLOR: #228b22"&gt;powershell&lt;/SPAN&gt; nil
  &lt;SPAN style="COLOR: #bc8f8f"&gt;"Running shell from within Emacs buffers."&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: #da70d6"&gt;:group&lt;/SPAN&gt; 'processes
  )


(&lt;SPAN style="COLOR: #a020f0"&gt;defcustom&lt;/SPAN&gt; &lt;SPAN style="COLOR: #b8860b"&gt;powershell-need-rawui-resize&lt;/SPAN&gt; t
  &lt;SPAN style="COLOR: #bc8f8f"&gt;"set when powershell needs to be resized"&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: #da70d6"&gt;:group&lt;/SPAN&gt; 'powershell
)

&lt;SPAN style="COLOR: #b22222"&gt;;;;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;###&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #ff0000"&gt;autoload&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;
&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a020f0"&gt;defun&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;powershell&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #228b22"&gt;&amp;amp;optional&lt;/SPAN&gt; buffer)
  &lt;SPAN style="COLOR: #bc8f8f"&gt;"Run an inferior powershell, by invoking the shell function. See the help for shell for more details.
\(Type \\[&lt;/SPAN&gt;&lt;SPAN style="COLOR: #5f9ea0"&gt;describe-mode&lt;/SPAN&gt;&lt;SPAN style="COLOR: #bc8f8f"&gt;] in the shell buffer for a list of commands.)"&lt;/SPAN&gt;
  (interactive
   (list
    (and current-prefix-arg
         (read-buffer &lt;SPAN style="COLOR: #bc8f8f"&gt;"Shell buffer: "&lt;/SPAN&gt;
                      (generate-new-buffer-name &lt;SPAN style="COLOR: #bc8f8f"&gt;"*PowerShell*"&lt;/SPAN&gt;)))))
  &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;get a name for the buffer
&lt;/SPAN&gt;  (setq buffer (get-buffer-create (or buffer &lt;SPAN style="COLOR: #bc8f8f"&gt;"*PowerShell*"&lt;/SPAN&gt;)))

  (&lt;SPAN style="COLOR: #a020f0"&gt;let&lt;/SPAN&gt; (
        (tmp-shellfile explicit-shell-file-name)
        )
                                        &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;set arguments for the powershell exe.
&lt;/SPAN&gt;                                        &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;This needs to be tunable.
&lt;/SPAN&gt;    (setq explicit-shell-file-name &lt;SPAN style="COLOR: #bc8f8f"&gt;"c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"&lt;/SPAN&gt;)  
    (setq explicit-powershell.exe-args '(&lt;SPAN style="COLOR: #bc8f8f"&gt;"-Command"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #bc8f8f"&gt;"-"&lt;/SPAN&gt; )) &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;interactive, but no command prompt
&lt;/SPAN&gt;  
                                        &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;launch the shell
&lt;/SPAN&gt;    (shell buffer)

    &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;restore the original shell
&lt;/SPAN&gt;    (&lt;SPAN style="COLOR: #a020f0"&gt;if&lt;/SPAN&gt; explicit-shell-file-name
        (setq explicit-shell-file-name tmp-shellfile)
      )
    )
  
  (&lt;SPAN style="COLOR: #a020f0"&gt;let&lt;/SPAN&gt; (
        (proc (get-buffer-process buffer))
        )
    
    &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;This sets up the powershell RawUI screen width. By default,
&lt;/SPAN&gt;    &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;the powershell v1.0 assumes terminal width of 80 chars.
&lt;/SPAN&gt;    &lt;SPAN style="COLOR: #b22222"&gt;;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;This means input gets wrapped at the 80th column.  We reset the
&lt;/SPAN&gt;    &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;width of the PS terminal to the window width. 
&lt;/SPAN&gt;    (add-hook 'window-size-change-functions 'powershell-window-size-changed)

    (powershell-window-size-changed)
    
    &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;ask for initial prompt
&lt;/SPAN&gt;    (comint-simple-send proc &lt;SPAN style="COLOR: #bc8f8f"&gt;"prompt"&lt;/SPAN&gt;)
    )

  &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;hook the kill-buffer action so we can kill the inferior process?
&lt;/SPAN&gt;  (add-hook 'kill-buffer-hook 'powershell-delete-process)

  &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;wrap the comint-input-sender with a PS version
&lt;/SPAN&gt;  &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;must do this after launching the shell! 
&lt;/SPAN&gt;  (make-local-variable 'comint-input-sender)
  (setq comint-input-sender 'powershell-simple-send)

  &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;set a preoutput filter for powershell.  This will trim newlines after the prompt.
&lt;/SPAN&gt;  (add-hook 'comint-preoutput-filter-functions 'powershell-preoutput-filter-for-prompt)

  &lt;SPAN style="COLOR: #b22222"&gt;;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;(run-hooks 'powershell-launch-hook)
&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;return the buffer created
&lt;/SPAN&gt;  buffer
)


(&lt;SPAN style="COLOR: #a020f0"&gt;defun&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;powershell-window-size-changed&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #228b22"&gt;&amp;amp;optional&lt;/SPAN&gt; frame)
  &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;do not actually resize here. instead just set a flag.
&lt;/SPAN&gt;  (setq powershell-need-rawui-resize t)
)



(&lt;SPAN style="COLOR: #a020f0"&gt;defun&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;powershell-delete-process&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #228b22"&gt;&amp;amp;optional&lt;/SPAN&gt; proc)
  (or proc
      (setq proc (get-buffer-process (current-buffer))))
  (and (processp proc)
       (delete-process proc))
  )



&lt;SPAN style="COLOR: #b22222"&gt;;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;This function trims the newline from the prompt that we
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;get back from powershell.  It is set into the preoutput
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;filters, so the newline is trimmed before being put into
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;the output buffer.
&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a020f0"&gt;defun&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;powershell-preoutput-filter-for-prompt&lt;/SPAN&gt; (string)
   (&lt;SPAN style="COLOR: #a020f0"&gt;if&lt;/SPAN&gt;
       &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;not sure why, but I have not succeeded in using a variable here???  
&lt;/SPAN&gt;       &lt;SPAN style="COLOR: #b22222"&gt;;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;(string-match  powershell-prompt-pattern  string)
&lt;/SPAN&gt;
       (string-match  &lt;SPAN style="COLOR: #bc8f8f"&gt;"PS [&lt;/SPAN&gt;&lt;SPAN style="COLOR: #bc8f8f"&gt;^&lt;/SPAN&gt;&lt;SPAN style="COLOR: #bc8f8f"&gt;#$%&amp;gt;]+&amp;gt;"&lt;/SPAN&gt; string)
       (substring string 0 -1)
     
     string

     )
   )



(&lt;SPAN style="COLOR: #a020f0"&gt;defun&lt;/SPAN&gt; &lt;SPAN style="COLOR: #0000ff"&gt;powershell-simple-send&lt;/SPAN&gt; (proc string)
  &lt;SPAN style="COLOR: #bc8f8f"&gt;"Override of the comint-simple-send function, specific for powershell.
This just sends STRING, plus the prompt command. Normally powershell is in
noninteractive model when run as an inferior shell with stdin/stdout
redirected, which is the case when running as a shell within emacs.
This function insures we get and display the prompt. "&lt;/SPAN&gt;
  &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;resize if necessary. We do this by sending a resize string to the shell,
&lt;/SPAN&gt;  &lt;SPAN style="COLOR: #b22222"&gt;; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b22222"&gt;before sending the actual command to the shell. 
&lt;/SPAN&gt;  (&lt;SPAN style="COLOR: #a020f0"&gt;if&lt;/SPAN&gt; powershell-need-rawui-resize
      (and
       (comint-simple-send proc (powershell-gen-window-width-string))
       (setq powershell-need-rawui-resize nil)
       )
    )
  (comint-simple-send proc string)
  (comint-simple-send proc &lt;SPAN style="COLOR: #bc8f8f"&gt;"prompt"&lt;/SPAN&gt;)
)
&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;To use it, you need to add in this text in your .emacs file: &lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: 1px; BORDER-TOP: 1px; BORDER-LEFT: 1px; BORDER-BOTTOM: 1px"&gt;&lt;PRE&gt;(autoload 'powershell "powershell" "Run powershell as a shell within emacs." t) &lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Start&amp;nbsp;powershell within emacs with &lt;B&gt;M-x powershell&lt;/B&gt;. You can continue to use the regular Windows shell within emacs via &lt;B&gt;M-x shell&lt;/B&gt;. &lt;/P&gt;
&lt;P&gt;Cheers!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8376018" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/dotnetinterop/attachment/8376018.ashx" length="5001" type="text/plain" /><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Interop/default.aspx">Interop</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Powershell/default.aspx">Powershell</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/emacs/default.aspx">emacs</category></item><item><title>IBM's new MQ Blog includes some good .NET stuff</title><link>http://blogs.msdn.com/dotnetinterop/archive/2007/02/16/ibm-s-mq-blog-includes-some-good-net-stuff.aspx</link><pubDate>Fri, 16 Feb 2007 20:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1685312</guid><dc:creator>DotNetInterop</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/dotnetinterop/comments/1685312.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dotnetinterop/commentrss.aspx?PostID=1685312</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;The MQ Engineers at &lt;A class="" href="http://blogs.msdn.com/ControlPanel/Blogs/www.ibm.com/uk/hursley" mce_href="http://blogs.msdn.com/ControlPanel/Blogs/www.ibm.com/uk/hursley"&gt;IBM’s Hursley Lab&lt;/A&gt; (near Winchester, England) now have &lt;A class="" href="http://hursleyonwmq.wordpress.com/" mce_href="http://hursleyonwmq.wordpress.com/"&gt;a blog&lt;/A&gt;.&amp;nbsp; (By the way, the Hursley campus is just &lt;EM&gt;gorgeous&lt;/EM&gt;.)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;The blog is pretty new, started only last month, as far as I can tell, but it is already chock-full of interesting, high-content posts.&amp;nbsp;&amp;nbsp; I learned about it when&amp;nbsp;Saket Rungta of IBM sent me an email. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;I want to call your attention to a couple of entries in particular.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 12pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;“&lt;B&gt;the Simplest MQ Publish/Subscribe Ever&lt;/B&gt;”, this one features &lt;A class="" href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython" mce_href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython"&gt;IronPython&lt;/A&gt;, and &lt;A class="" href="http://www-128.ibm.com/developerworks/websphere/library/techarticles/0509_phillips/0509_phillips.html" mce_href="http://www-128.ibm.com/developerworks/websphere/library/techarticles/0509_phillips/0509_phillips.html"&gt;XMS.NET&lt;/A&gt;.&lt;BR&gt;&lt;BR&gt;The author shows how to build a publisher and a subscriber, in python running on .NET.&amp;nbsp; The app uses the XMS.NET library to connect to the MQ Resource.&amp;nbsp; Nifty!&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;A href="http://hursleyonwmq.wordpress.com/2007/02/13/simplest-websphere-mq-publishsubscribeever/"&gt;&lt;FONT face=Calibri size=3&gt;http://hursleyonwmq.wordpress.com/2007/02/13/simplest-websphere-mq-publishsubscribeever/&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;“&lt;B&gt;WebSphere MQ Scripting using PowerShell&lt;/B&gt;”&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;A href="http://hursleyonwmq.wordpress.com/2007/02/12/websphere-mq-scripting-using-powershell/"&gt;&lt;FONT face=Calibri color=#0000ff size=3&gt;http://hursleyonwmq.wordpress.com/2007/02/12/websphere-mq-scripting-using-powershell/&lt;/FONT&gt;&lt;/A&gt;&lt;BR&gt;&lt;BR&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;This is pretty cool.&amp;nbsp;&amp;nbsp; See, here's the thing about &lt;/FONT&gt;&lt;A class="" href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" mce_href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx"&gt;&lt;FONT size=3&gt;Powershell&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt; - it is a .NET-enabled scripting environment, so if you have a .NET class library (Such as IBM's &lt;/FONT&gt;&lt;A class="" href="http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.csqzav.doc/csq870z.htm" mce_href="http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.csqzav.doc/csq870z.htm"&gt;&lt;FONT size=3&gt;MQ Classes for .NET&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;), you can do pretty much anything that is enabled by that class library.&amp;nbsp; Which means, from the script you can create queues, clear queues, delete queues, and so on.&amp;nbsp; Anything you can do from the class library. &lt;BR&gt;&lt;BR&gt;One editorial comment: &lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;One of the ideas embraced by PowerShell is that APIs are not the right level of abstraction for Administrators.&amp;nbsp; PowerShell introduces the ideas of "Cmdlets" and&amp;nbsp;"functions" - very small pieces of code focused on delivering the right user experience to admins and other people who would use scripts.&amp;nbsp; It would be cool to have a powershell library for MQ - something with&amp;nbsp;&lt;A class="" href="http://msdn2.microsoft.com/en-us/library/ms714428.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms714428.aspx"&gt;the right level of verb-noun abstractions&lt;/A&gt;.&amp;nbsp; I imagine it would be a pretty thin layer.&amp;nbsp; &lt;SPAN style="COLOR: #1f497d"&gt;&lt;FONT size=3&gt;It's on my increasingly long list of things to investigate. &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Calibri&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;FONT size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT size=3&gt;Kudos to IBM for the new blog!&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1685312" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Interop/default.aspx">Interop</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/MQ/default.aspx">MQ</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Powershell/default.aspx">Powershell</category></item></channel></rss>