<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2901536678118207539</id><updated>2012-02-16T12:18:10.251+01:00</updated><title type='text'>All sorts</title><subtitle type='html'>Information about some aspects of my life as a proud dad, billiards player, chess aficionado, and yes, also work.... in short: All sorts.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-7911895608076497085</id><published>2011-12-15T13:29:00.002+01:00</published><updated>2011-12-22T14:31:45.165+01:00</updated><title type='text'>Lambda expressions in .Net (C#)</title><content type='html'>&lt;br /&gt;&lt;div style="border-bottom: solid #4F81BD 1.0pt; border: none; mso-border-bottom-themecolor: accent1; mso-element: para-border-div; padding: 0in 0in 4.0pt 0in;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Dynamically creating lambda expressions in .Net (C#)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;div class="MsoTitle"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoTitle"&gt;&lt;b&gt;Passing lambda expressions as strings&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;In a situation where you want to allow auser to create his own lambda expressions at runtime, there are not a lot ofoptions. Whether you read the expression from a file, or an input box, you endup with a string that you wish to convert. There is no method in .Net 4.0 thatlets you do just that (easily).&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;But as for most things, workarounds exist. Below is the one I’m using. Better solutions are very welcome.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Suppose you want to call Regex.Replace witha lambda expression for the MatchEveluator. At design time this is easy:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&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; Regex.Replace(“MyInputString”,@”\B[A-Z]”, m =&amp;gt; “ “ + m.ToString().ToLower());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;This results in:&lt;b&gt; "My input string"&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;But when the lambda expression is a string,that won’t work:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: .5in;"&gt;&lt;span lang="EN-US"&gt;String input = “MyInputString”;&lt;br /&gt;String expr = @”\B[A-Z]”;&lt;br /&gt;String lambda = “m =&amp;gt; \” \” + m.ToString().ToLower();&lt;br /&gt;Regex.Replace(input, expr, lambda);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;This results in:&lt;b&gt; &amp;nbsp;"Mym =&amp;gt; \" \" + m.ToString().ToLower()nputm =&amp;gt;\" \" + m.ToString().ToLower()tring"&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;Logical, but not quite what’s intended.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;In order to convert the string to a truelambda expression would take considerable effort. However, creating a regular ‘method’at runtime is a lot easier. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;The question then becomes: how can weleverage the normal compiler routines in compiling lambda ‘strings’. Here’s anexample. It requires 3 steps:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;b&gt;&lt;u&gt;&lt;i&gt;Step 1: create a method that builds of thebody of a class and method&lt;/i&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;private string createRegexClassInMemory(&lt;br /&gt;&amp;nbsp; &amp;nbsp; string input, &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; string expr, &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; string lambda, &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; RegexOptions regexOptions = RegexOptions.None) { &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; StringBuilder classbuilder = new StringBuilder("using System;”);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; classbuilder.Append(“using System.Text;");&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; classbuilder.Append(“using System.Text.RegularExpressions;");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Note that we need to double escape 'escapes' and double accolade 'accolades'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; classbuilder.AppendFormat("namespace {0}{{", GetType().Namespace);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; classbuilder.Append(@"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public class RegexLambdaClass{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public static string RegexLambda(){");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Note that we need to double escape 'escapes', except for the lambda expression, as it gets handled differently&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; input = input.Replace("\\", "\\\\");&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; expr = expr.Replace("\\", "\\\\");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Note the lack of double-quotes around the third parameter !!!!!! &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; classbuilder.AppendFormat("return Regex.Replace(\"{0}\", \"{1}\", {2}, RegexOptions.{3});", &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; input, &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; expr, &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lambda, &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; regexOptions);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; classbuilder.Append("}}}");&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return classbuilder.ToString();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Step 2: create a module to compile and run this code&lt;/span&gt;&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The code below has been adapted from “&lt;a href="http://www.codeproject.com/KB/cs/runtimecompiling.aspx"&gt;http://www.codeproject.com/KB/cs/runtimecompiling.aspx&lt;/a&gt;”.&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;using System;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;using System.Text;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;using Microsoft.CSharp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;using System.CodeDom.Compiler;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;using System.Reflection;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;using System.Text.RegularExpressions;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;namespace Invocation&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; /// Example&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; /// /x myNamespace MyClass MyFunction False param1,param2,param3,etc&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; /// The False states that MyFunction is not static.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; /// This class can be used to execute dynamic uncompiled code at runtime&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; /// This class is not exception safe, all function calls should be exception handled.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; public class CodeCompiler&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private CompilerParameters compilerparams = new CompilerParameters();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Default Constructor.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// It is necessary to have an instance of the class so that the reflection&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// can get the namespace of this class dynamically.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;remarks&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// This class could be static, but I wanted to make it easy for developers&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// to use this class by allowing them to change the namespace without&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// harming the code.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;/remarks&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public CodeCompiler()&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; compilerparams.GenerateExecutable = false;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; compilerparams.GenerateInMemory = true;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Add System reference&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.addReference(typeof(System.String).Assembly.Location);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void clearReferences() {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; compilerparams.ReferencedAssemblies.Clear();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void addReference(string reference)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; compilerparams.ReferencedAssemblies.Add(reference);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// This is the main code execution function.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// It allows for any compilable c# code to be executed.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;param name="code"&amp;gt;the code to be compiled then executed&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;param name="namespacename"&amp;gt;the name of the namespace to be executed&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;param name="classname"&amp;gt;the name of the class of the function in the code that you will execute&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;param name="functionname"&amp;gt;the name of the function that you will execute&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;param name="isstatic"&amp;gt;True if the function you will execute is static, otherwise false&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;param name="args"&amp;gt;any parameters that must be passed to the function&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;returns&amp;gt;&lt;returns&gt;what ever the executed function returns, in object form&lt;/returns&gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public object ExecuteCode(string code, string namespacename, string classname,&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string functionname, bool isstatic, params object[] args)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; object returnval = null;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Assembly asm = BuildAssembly(code);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; object instance = null;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Type type = null;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (isstatic) {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; type = asm.GetType(namespacename + "." + classname);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; instance = asm.CreateInstance(namespacename + "." + classname);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; type = instance.GetType();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MethodInfo method = type.GetMethod(functionname);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; returnval = method.Invoke(instance, args);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return returnval;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// This private function builds the assembly file into memory after compiling the code&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name="code"&amp;gt;C# code to be compiled&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&amp;lt;returns&amp;gt;the compiled assembly object&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private Assembly BuildAssembly(string code)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Microsoft.CSharp.CSharpCodeProvider provider = new CSharpCodeProvider();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CompilerResults results = provider.CompileAssemblyFromSource(compilerparams, code);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (results.Errors.HasErrors)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; StringBuilder errors = new StringBuilder("Compiler Errors :\r\n");&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach (CompilerError error in results.Errors)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; errors.AppendFormat("Line {0},{1}\t: {2}\n", error.Line, error.Column, error.ErrorText);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw new Exception(errors.ToString());&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return results.CompiledAssembly;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;Step 3: call the code above&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: inherit; font-size: x-small;"&gt;            Invocation.CodeCompiler cc = new Invocation.CodeCompiler();&lt;br /&gt;             //  We need to add the necessary references !!!!!&lt;br /&gt;             cc.addReference(typeof(System.Text.RegularExpressions.Regex).Assembly.Location);&lt;br /&gt;             string result = (string)cc.ExecuteCode(&lt;br /&gt;&amp;nbsp; &amp;nbsp; createRegexClassInMemory(&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; input,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; expr,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lambda,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; regexOptions: RegexOptions.IgnoreCase),&lt;br /&gt;&amp;nbsp; &amp;nbsp; GetType().Namespace,&lt;br /&gt;&amp;nbsp; &amp;nbsp; "RegexLambdaClass",&lt;br /&gt;&amp;nbsp; &amp;nbsp; "RegexLambda", true);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="MsoNormal"&gt;&lt;hr /&gt;&lt;span lang="EN-US"&gt;Note that if you don’t need lambdaexpressions, you could add the parameters as proper ‘method’ parameters. Thebuild-up and execution code could then be as follows:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;private string createRegexClassInMemory() {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; StringBuilder classbuilder = new StringBuilder("using System;”);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; classbuilder.Append(“using System.Text;");&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; classbuilder.Append(“using System.Text.RegularExpressions;");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; // Note that we need to double escape 'escapes' and double accolade 'accolades'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; classbuilder.AppendFormat("namespace {0}{{", GetType().Namespace);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; classbuilder.Append(@"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public class RegexLambdaClass{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public static string RegexNoLambda(string input, string expr, MatchEvaluator me, RegexOptions regexOptions = RegexOptions.None){");&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; classbuilder.Append("return Regex.Replace(input, expr, me, regexOptions);");        classbuilder.Append("}}}");&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; return classbuilder.ToString();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Invocation.CodeCompiler cc = new Invocation.CodeCompiler();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt; //  We need to add the necessary references !!!!!&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt; cc.addReference(typeof(System.Text.RegularExpressions.Regex).Assembly.Location);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt; string result = (string)cc.ExecuteCode(&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; createRegexClassInMemory(),&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; GetType().Namespace,&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; "RegexLambdaClass",&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; "RegexLambda", true,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&amp;nbsp; &amp;nbsp; input, expr, new MatchEvaluator(delegate),  RegexOptions.IgnoreCase);&lt;/span&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: Arial, sans-serif; font-size: 8pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-7911895608076497085?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/7911895608076497085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=7911895608076497085&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/7911895608076497085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/7911895608076497085'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2011/12/lambda-expressions.html' title='Lambda expressions in .Net (C#)'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-2260308865072155514</id><published>2011-12-07T22:19:00.000+01:00</published><updated>2011-12-07T22:47:29.068+01:00</updated><title type='text'>Metro</title><content type='html'>&lt;i&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #a64d79;"&gt;you can check out any time you like, but you can never leave&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Taking the metro&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Embarking on new travels; mostly by car, sometimes by bus or train, this time by metro.&lt;br /&gt;Living in the Netherlands I've given up on the train- and bus-thing, as it is simply to cumbersome, error prone and riddled with cost-incurring 'facilities'.&lt;br /&gt;You can read all about it on the internet.&lt;br /&gt;So the launch of a new metro was right up my alley, and I was&amp;nbsp;privileged&amp;nbsp;to be allowed a test-run. Which I did.&lt;br /&gt;Before continuing, I want you to know that from buses and trains you can easily leave (note that you pay extra for not checking out; very much so in the case of trains).&lt;br /&gt;By the way, leaving&amp;nbsp;while it's still running falls in the category "don't try this at home dude"; which you couldn't anyway by virtue of not being at home, seeing as you're in the bus or train.&lt;br /&gt;Well, it's all different in the metro. Oh yes. Checking out or not checking out makes hardly any difference (except for clotting up part of the brain). &lt;b&gt;&lt;u&gt;BUT YOU CAN NEVER LEAVE.&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;Here's my story&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So I got on this brand new metro. It's not quite finished, and thus I need to stay flexible and open-minded. I thought I was.....&lt;br /&gt;Drove around, tried some of the new features, got stuck in the features (eventually throwing them on a big heap and leaving them to rot), got expelled back to the good ol' black-top, been dragged along, managed to hop on the metro again, but couldn't find the exit. Oh bummer.&lt;br /&gt;Heck, even in 'expelled' state there was no way to truly leave....&lt;br /&gt;Who was it wrote: you can check out any time you like, but you can never leave.&lt;br /&gt;But hey, that's okay, I didn't really wanna leave yet, fully trusting in finding the exit later (as I am writing this from home, I clearly did, so don't worry your pants off - it would leave me with a mental image I am not too keen on).&lt;br /&gt;Played the piano (cool eh, a piano in the metro), threw it on the heap...&lt;br /&gt;Played sudoku, threw it on the heap...&lt;br /&gt;Tried the ink-pad...&lt;br /&gt;Hey, hold on a minute.... sudoku I can tear up and throw in the bin.... ah, got that sorted neatly (notice that in this brave new world I can conjure up a new sudoku in no time flat)&lt;br /&gt;Hmmm.... a piano lid can be slammed shut.&lt;br /&gt;Chess boards can be smashed to&amp;nbsp;smithereens....&lt;br /&gt;Seems like every feature can be destructed if one truly wishes to do so....&lt;br /&gt;Ahh.... thus one worry less.&lt;br /&gt;Would this work for the whole metro? Nope. It will not allow itself to be destroyed so easily. Leaving metro is a whole different story. I eventually manged by crawling in a far corner, prying open a panel, clicking a button, and finally leaving...&lt;br /&gt;It was a trip I'm not likely going to forget any time soon... Will I be&amp;nbsp;sufficiently&amp;nbsp;disturbed to try it again some other time? No doubt.....&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;Microsoft Windows 8 with the new Metro UI&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you like to try Windows 8 with the new Metro UI yourself, then please do so in a Virtual Machine. The latest VirtualBox (by Oracle) has knowledge of Windows 8 making the installation a breeze.&lt;br /&gt;Some Metro-apps throw you right back to the old desktop when they're started, which is rather confusing.&lt;br /&gt;Most (if not all) 'metro-apps' can be closed by using Alt-F4 (yes, the very old Windows Alt-F4), but you'll probably loose any unsaved data.&amp;nbsp;(Alt-F4 ends up in a blank screen - green in my case - on which you can click to get back to Metro).&lt;br /&gt;Shutting down Windows is possible, but it requires some searching (left-bottom corner hover, followed by settings, followed by power, followed by shutdown).&lt;br /&gt;&lt;br /&gt;Still, Microsoft is working on the environment as we speak, hopefully ironing out most of the issues.&lt;br /&gt;I'll give it another test-drive in 2012.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Be brave&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-2260308865072155514?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/2260308865072155514/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=2260308865072155514&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/2260308865072155514'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/2260308865072155514'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2011/12/metro.html' title='Metro'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-4312031575063110654</id><published>2011-09-08T22:15:00.000+02:00</published><updated>2011-09-08T22:28:48.827+02:00</updated><title type='text'>Ferrari: a Point to Share</title><content type='html'>&lt;br /&gt;&lt;div style="border-bottom: solid #4F81BD 1.0pt; border: none; mso-border-bottom-themecolor: accent1; mso-element: para-border-div; padding: 0in 0in 4.0pt 0in;"&gt;&lt;h1&gt;&lt;span class="Apple-style-span" style="font-size: small; font-weight: normal;"&gt;What's the point of having a great system if you're not allowed to use it. Here's my take on it.&lt;/span&gt;&lt;/h1&gt;&lt;/div&gt;&lt;h1&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;h1&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;What ?!??!&lt;/span&gt;&lt;/h1&gt;&lt;h1 style="font-size: medium; font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-size: small; font-weight: normal;"&gt;A Ferrari going 10 miles an hour on 3 wheels, while listening to your favorite music on the latest iPod-Nano, plugged into universal media connector. What ?!?!!???&lt;/span&gt;&lt;/h1&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;h1&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;My birthday&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;I was going to be 18, and was ecstatic tolearn that my mom and dad had bought me a Ferrari. No, not a matchbox type(that would really ruin this story), but a real one (yellow if you care toknow). Didn’t believe it at first, thought I was dreaming. But I wasn’t….&amp;nbsp; So I called all my friends to take her for aspin….&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;h1&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;feRRaRi&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;The motor puRRed……Nice!!!!!! A gentlestart…. 2 Mph, 5 Mph, 7 Mph….. really getting the hang of it now…. 10 Mph… 10Mph… 10 Mph…. terrible scraping noise…. and sitting crooked to boot.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Ok, so there’s clearly something wrong here.I already thought something fishy was going on when I spotted only 3 wheels;but not being able to go faster than 10Mph in a Ferrari?!??!? Surely themachine must be broken. Techno-savvy as I am I assumed a reboot was needed, soI stopped the car, got out (that’s important, as otherwise the sensors mightthink you’re still driving, and thus failing on the reboot) , got back in(equally important, as otherwise driving gets really difficult, esp. seeing asmy dad had removed the remote control for safety reasons), started the caragain, and of we went… at a whopping 10 Mph.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;h1&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;My dad; Gotta love this guy&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;So what happened? Being conscientious as heis, he had decided to limit to speed of my brand-new-all-out-honest-to-godFerrari. For two reasons: environment and safety. Furthermore, he had removedone wheel so that he could save on the cost of this fantastic machine.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;h1&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;My Ferrari being a Share Point&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Having gotten to grips with the situation,we decided to talk about all this in my new car (or what’s left of it). I mean,what else could I use it for, other than having a cup of coffee and collaborateon possible changes that would render the machine somewhat useful (or at leasta bit less useless). Funny though, my that had a UMC specially fitted. One inthe front and one in the back. If was perfect for my Nano, giving us somereally nice background music. Not to mention the coffee-maker stuck on theceiling…&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;h1&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Back to business&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;If you believed the story above to be true,then this story really is for you. You see, the above actually does happen on aregular basis. Not with Ferrari’s I’d have to admit, but with the Ferrariamongst Web-Portal-Collaboration-Software called SharePoint.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Companies go all out buying this ratherexpensive piece of tooling, and then strip it down, because they don’t trustthe users to behave. So where the tooling is designed to allow end-users tointeract with, and setup new web-sites and pages, companies try to remove theoptions for fear of “web-site proliferation”. Unwarranted fear in my mind.True, when given the rights, end-users will experiment and create new sites.But isn’t that the whole idea? Isn’t that why you bought SharePoint… so thatnew sites can be easily created. And who knows better what they want from a newsite then the actual user?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Instead, a small group of individuals hasbeen tasked with deciding what users want, and create the sites for them(including some fancy shmancy functionality no one really needs); invariablyresulting in sites that are painfully underused. An embarrassment even. Is thetruth hurting already? Are you feeling the pain I deliver?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;And why the fear? Take the followingscenario:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Project teams have a need to collaborate.The team-lead or project-lead gets accredited with the rights to create projectsites.&lt;br /&gt;Now how many project-sites is he going to create? One, five, one hundred? Idare bet that (s)he will create a maximum of five project sites. No more…&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;“But” you say “what if he creates 25; andall his friends as well”. Here’s the parry: have administrators monitor theamount of sites per user. Should this fall above a threshold, then issue awarning. Does the culprit not listen? Then remove the rights to create sites. Nowthis is time and money well spent; and proliferation will soon die out, Iassure you.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;h1&gt;&lt;span lang="EN-US"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Educate&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;The point I’m trying to make is that itseems much wiser to not cripple the tooling you spent so much money on (and theaction of crippling typically costs way more than the initial outlay), butinstead educate people in the proper usage of your great piece of software. Useit to its full potential, and give end-users what they really want (not whatyou believe they should want), by giving them freedom and flexibility. Sure,provide them with extras, shortcuts, easy to use modules, and perhaps fix thebranding. By all means, help them along by setting up an initial site for them. But do notlimit the potential.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;Don’t give your employees a 3-wheeledFerrari doing a max of 10Mph, out of pure fear. Instead give them the Ferrariyou can afford, and teach them how to drive and use it safely and properly.Keep an eye on them, and let them know when they cross the line. Revoke theirlicense if they don’t listen. But please don’t punish the good citizens bylimiting functionality. Punish the culprits instead by revoking theirlicense…..&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;u&gt;Don't be like my dad.&lt;/u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-4312031575063110654?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/4312031575063110654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=4312031575063110654&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/4312031575063110654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/4312031575063110654'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2011/09/ferrari-point-to-share.html' title='Ferrari: a Point to Share'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-5628903477321170881</id><published>2010-03-24T22:14:00.012+01:00</published><updated>2011-02-01T09:26:50.673+01:00</updated><title type='text'>Running Windows 2008 (runtime) off a USB Drive Without VHD</title><content type='html'>&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="background-color: #ffd966; font-family: Verdana, sans-serif;"&gt;This post describes installing MS-Windows 2008 on a USB Drive without the help of a Virtual Hard Drive (VHD). In an &lt;a href="http://edwinroestenburg.blogspot.com/2010/03/running-windows-runtime-from-usb.html"&gt;earlier post&lt;/a&gt; I described how to do this WITH a VHD.&lt;/span&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Installing windows onto a USB device requires quite some steps. In what situations this is possible I cannot say, but it obviously works in some.&lt;br /&gt;&lt;br /&gt;Below is a description of a Windows 7 installation setting up a new USB HardDisk with "Hyper-V Windows Server 2008 R2".&lt;br /&gt;Let's take every single step into account.&lt;br /&gt;&lt;br /&gt;(Intermezzo's are used to show errors you would get when skipping steps. One of them is important.)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Assumptions&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;Your USB HDD drive letter is going to be "U:".&lt;br /&gt;Your DVDDrive has drive letter "V:".&lt;br /&gt;You have &lt;strong&gt;administrator rights&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Tools needed&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;Your Windows Installation Disk.&lt;br /&gt;BootSect.exe (can be found in the "Boot" directory of your windows install disk).&lt;br /&gt;Windows Automated Installation Kit (WAIK) (Needed for ImageX).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Steps&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;1 - You will need access to the BIOS setup.&lt;br /&gt;Make sure that your BIOS supports booting into a USB device.&lt;br /&gt;&lt;br /&gt;2 - If you've got a brand &lt;strong&gt;new drive&lt;/strong&gt;, you will need to &lt;strong&gt;initialize it&lt;/strong&gt;. You can do this in Window's Disk Management tool, which is available in all windows versions.&lt;br /&gt;&lt;br /&gt;Make sure you choose for NTFS. Give it a drive letter (we need it later). For the rest of this tutorial, I will assume drive letter "U:".&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;INTERMEZZO: &lt;br /&gt;Trying to boot from the USB Drive will now give the following error.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;Non-System disk or disk error. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;Replace and strike any key when ready.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;3 - Make sure the partition on the USB HDD that you wish to install in is &lt;strong&gt;Active&lt;/strong&gt;. You can do this in de Windows Disk Management.&lt;br /&gt;(This step got me going for a while……)&lt;br /&gt;Note that the option to mark the partition as active will be greyed out if the partition is active by default.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_8QuMOYSBFtc/S5od6cc7MuI/AAAAAAAAABg/3ZUgoI0ZJ2g/s1600-h/p3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="371" src="http://1.bp.blogspot.com/_8QuMOYSBFtc/S5od6cc7MuI/AAAAAAAAABg/3ZUgoI0ZJ2g/s400/p3.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Install WAIK. You should now have three "ImageX" executables (one for AMD64, one for Intel64, and one for 32 bits.) These can be found in C:\Program Files\Windows AIK\Tools.&lt;br /&gt;&lt;br /&gt;NOTE: For me the only one working was the AMD version, although I have an Intel T5500 processor !!?!??!?!&lt;br /&gt;&lt;br /&gt;5 - Open an &lt;strong&gt;elevated &lt;/strong&gt;command prompt.&lt;br /&gt;Go to the correct WAIK directory for your machine.&lt;br /&gt;Type the following command (&lt;strong&gt;DO NOT FORGET THE DRIVELETTER:&lt;/strong&gt;)&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;BootSect /nt60 U:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;Note the &lt;strong&gt;colon&lt;/strong&gt;. &lt;br /&gt;(&lt;strong&gt;Bootsect&lt;/strong&gt;.exe updates the master boot code for hard disk partitions to switch between BOOTMGR and NTLDR.)&lt;br /&gt;&lt;br /&gt;Leave the CMD open. We'll need it again later.&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="background-color: #e06666; font-size: large;"&gt;IMPORTANT&lt;/span&gt;&lt;br /&gt;We need to make sure that your machine can actually boot into the USB Drive before we continue. Make sure the USB Drive is the first to boot so that a automatic restart will go back to the USB Drive.&lt;br /&gt;&lt;br /&gt;Try it now, and make sure you get the following error when rebooting your machine. After that, boot back into windows so you can continue with this tutorial.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;INTERMEZZO: &lt;br /&gt;Trying to boot from the USB Drive will now give the following error.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;BOOTMGR is missing.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;Press Ctrl+Alt+Del to restart.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;INTERMEZZO: &lt;br /&gt;If you were now trying to install Windows onto the USB Drive, you would receive the following error:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_8QuMOYSBFtc/S5lmzf_7A5I/AAAAAAAAABQ/XIy6FToXsME/s1600-h/p1.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="297" src="http://4.bp.blogspot.com/_8QuMOYSBFtc/S5lmzf_7A5I/AAAAAAAAABQ/XIy6FToXsME/s400/p1.png" vt="true" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_8QuMOYSBFtc/S5lm-tgeplI/AAAAAAAAABY/8o6OEqAqTpQ/s1600-h/p2.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="164" src="http://4.bp.blogspot.com/_8QuMOYSBFtc/S5lm-tgeplI/AAAAAAAAABY/8o6OEqAqTpQ/s400/p2.png" vt="true" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6 - In de Elevated CMD run the following:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;imagex /info V:\sources\install.wim&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;This will show you all the entries (or versions) available in the WIM-file; Hyper-V Server 2008 R2 has only one entry; it will have "index 1". No changes have been made yet.&lt;br /&gt;&lt;br /&gt;Remember that V: was assumed to be the drive letter of your DVD Drive (where the Windows Install disk lives).&lt;br /&gt;&lt;br /&gt;With the previously found index number, run the following:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;imagex /apply /check /verify V:\sources\install.wim 1 U:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;This step takes a while, and will place a complete image of the Windows version you want to install onto the USB drive. &lt;br /&gt;&lt;br /&gt;7 - Boot files&lt;br /&gt;Let's copy the necessary boot file to the USB Drive (use the elevated DOS prompt again):&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;bcdboot U:\Windows /s U: /v&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;(Note: if this fails it may help to disconnect and reconnect the USB Drive.)&lt;br /&gt;&lt;br /&gt;8 - Clean up&lt;br /&gt;You can now close the CMD where you ran BcdBoot.&lt;br /&gt;&lt;br /&gt;Remove your Windows Install disk from the drive. It is no longer needed.&lt;br /&gt;&lt;br /&gt;Reboot the machine, and make sure the FIRST boot device is the USB Drive. Windows may want to reboot a few times, and it would be annoying if it would boot into the wrong version.&lt;br /&gt;&lt;br /&gt;Boot into the USB Drive and see the magic happen.&lt;br /&gt;&lt;hr /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-5628903477321170881?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/5628903477321170881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=5628903477321170881&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/5628903477321170881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/5628903477321170881'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2010/03/running-windows-runtime-off-usb-drive.html' title='Running Windows 2008 (runtime) off a USB Drive Without VHD'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_8QuMOYSBFtc/S5od6cc7MuI/AAAAAAAAABg/3ZUgoI0ZJ2g/s72-c/p3.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-2106091886664898879</id><published>2010-03-11T23:07:00.023+01:00</published><updated>2011-02-01T21:42:26.654+01:00</updated><title type='text'>Running Windows 7 / 2008 (runtime) off a USB Drive using a VHD</title><content type='html'>&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="background-color: #ffd966; font-family: Verdana, sans-serif;"&gt;This post describes installing MS-Windows 7 or MS-Windows 2008 on a USB Drive with help of a Virtual Hard Drive (VHD). In a &lt;a href="http://edwinroestenburg.blogspot.com/2010/03/running-windows-runtime-off-usb-drive.html"&gt;later post&lt;/a&gt; I describe how to do this WITHOUT a VHD (which is easier for Windows 2008 but more complex for Windows 7).&lt;/span&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Installing MS-Windows 7 or MS-Windows 2008 onto a USB device requires quite some steps. In what situations this is possible I cannot say, but it obviously works in some.&lt;br /&gt;&lt;br /&gt;Below is a description of a Windows 7 installation setting up a new USB HardDisk with "Hyper-V Windows Server 2008 R2".&lt;br /&gt;Let's take every single step into account.&lt;br /&gt;&lt;br /&gt;(Intermezzo's are used to show errors you would get when skipping steps. One of them is important.)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Assumptions&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;Your USB HDD drive letter is going to be "U:".&lt;br /&gt;Your DVDDrive has drive letter "V:".&lt;br /&gt;You have &lt;strong&gt;administrator rights&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Tools needed&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;Your Windows Installation Disk.&lt;br /&gt;BootSect.exe (can be found in the "Boot" directory of your windows install disk).&lt;br /&gt;Windows Automated Installation Kit (WAIK) (Needed for ImageX).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Steps&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;1 - You will need access to the BIOS setup.&lt;br /&gt;Make sure that your BIOS supports booting into a USB device.&lt;br /&gt;&lt;br /&gt;2 - If you've got a brand &lt;strong&gt;new drive&lt;/strong&gt;, you will need to &lt;strong&gt;initialize it&lt;/strong&gt;. You can do this in Window's Disk Management tool, which is available in all windows versions.&lt;br /&gt;&lt;br /&gt;Make sure you choose for NTFS. Give it a drive letter (we need it later). For the rest of this tutorial, I will assume drive letter "U:".&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;INTERMEZZO: &lt;br /&gt;Trying to boot from the USB Drive will now give the following error.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;Non-System disk or disk error. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;Replace and strike any key when ready.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;3 - Make sure the partition on the USB HDD that you wish to install in is &lt;strong&gt;Active&lt;/strong&gt;. You can do this in de Windows Disk Management.&lt;br /&gt;(This step got me going for a while……)&lt;br /&gt;Note that the option to mark the partition as active will be greyed out if the partition is active by default.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_8QuMOYSBFtc/S5od6cc7MuI/AAAAAAAAABg/3ZUgoI0ZJ2g/s1600-h/p3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="371" src="http://1.bp.blogspot.com/_8QuMOYSBFtc/S5od6cc7MuI/AAAAAAAAABg/3ZUgoI0ZJ2g/s400/p3.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Install WAIK. You should now have three "ImageX" executables (one for AMD64, one for Intel64, and one for 32 bits.) These can be found in C:\Program Files\Windows AIK\Tools.&lt;br /&gt;&lt;br /&gt;NOTE: For me the only one working was the AMD version, although I have an Intel T5500 processor !!?!??!?!&lt;br /&gt;&lt;br /&gt;5 - Open an &lt;strong&gt;elevated &lt;/strong&gt;command prompt.&lt;br /&gt;Go to the correct WAIK directory for your machine.&lt;br /&gt;Type the following command (&lt;strong&gt;DO NOT FORGET THE DRIVELETTER:&lt;/strong&gt;)&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;BootSect /nt60 U:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;Note the &lt;strong&gt;colon&lt;/strong&gt;. &lt;br /&gt;(&lt;strong&gt;Bootsect&lt;/strong&gt;.exe updates the master boot code for hard disk partitions to switch between BOOTMGR and NTLDR.)&lt;br /&gt;&lt;br /&gt;Leave the CMD open. We'll need it again later.&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="background-color: #e06666; font-size: large;"&gt;IMPORTANT&lt;/span&gt;&lt;br /&gt;We need to make sure that your machine can actually boot into the USB Drive before we continue. Make sure the USB Drive is the first to boot so that a automatic restart will go back to the USB Drive.&lt;br /&gt;&lt;br /&gt;Try it now, and make sure you get the following error when rebooting your machine. After that, boot back into windows so you can continue with this tutorial.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;INTERMEZZO: &lt;br /&gt;Trying to boot from the USB Drive will now give the following error.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;BOOTMGR is missing.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;Press Ctrl+Alt+Del to restart.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;INTERMEZZO: &lt;br /&gt;If you were now trying to install Windows onto the USB Drive, you would receive the following error:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_8QuMOYSBFtc/S5lmzf_7A5I/AAAAAAAAABQ/XIy6FToXsME/s1600-h/p1.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="297" src="http://4.bp.blogspot.com/_8QuMOYSBFtc/S5lmzf_7A5I/AAAAAAAAABQ/XIy6FToXsME/s400/p1.png" vt="true" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_8QuMOYSBFtc/S5lm-tgeplI/AAAAAAAAABY/8o6OEqAqTpQ/s1600-h/p2.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="164" src="http://4.bp.blogspot.com/_8QuMOYSBFtc/S5lm-tgeplI/AAAAAAAAABY/8o6OEqAqTpQ/s400/p2.png" vt="true" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6 - Now things get complicated. &lt;br /&gt;First we are going to create a VHD in which we can place an Image of the Windows version we want to install. In this tutorial I will call this Image.VHD. Note that this VHD is also the one that will eventually be used for new Windows Install. Make sure it's big enough, or make its size dynamic. (I've used fixed for my test, but I intend to change that). For permanent use I would recommend a name like "Win2K8R2_Image.VHD".&lt;br /&gt;&lt;br /&gt;In the CMD we still have open:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;Diskpart&lt;/span&gt;&lt;br /&gt;(Starts the disk management CMD-utility)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;create vdisk file=U:\Image.vhd maximum=14500 type=fixed &lt;/span&gt;&lt;br /&gt;(This creates a VHD on the USB Drive with the size 14500 MB. As this file will later hold the actual Windows Version, it should be placed on the USB device, where it can be found by the boot manager. (This step will take a few minutes.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;select vdisk file=U:\Image.vhd &lt;/span&gt;&lt;br /&gt;(Selects the created disk)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;attach vdisk &lt;/span&gt;&lt;br /&gt;(Attaches it so Windows can see it)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;list disk &lt;/span&gt;&lt;br /&gt;(Shows you all the disks in the system, &lt;strong&gt;note the number &lt;/strong&gt;of your newly created VHD)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;select disk disknumber &lt;/span&gt;&lt;br /&gt;(Selects the newly created VHD)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;create partition primary &lt;/span&gt;&lt;br /&gt;(Creates a primary partition)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;select partition 1 &lt;/span&gt;&lt;br /&gt;(Selects the primary partition)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;active &lt;/span&gt;&lt;br /&gt;(Sets it to active)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;format fs=ntfs quick &lt;/span&gt;&lt;br /&gt;(Format it with NTFS and do it quick)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;assign&lt;/span&gt;&lt;br /&gt;(Assigns a driveletter)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;list volume&lt;/span&gt;&lt;br /&gt;(&lt;strong&gt;Note the driveletter the new drive got&lt;/strong&gt;!)&lt;/div&gt;&lt;br /&gt;Leave DiskPart open and start a new CMD with administrative rights.&lt;br /&gt;Please take note of the &lt;strong&gt;DriveLetter assigned&lt;/strong&gt;. This will be referred to as &lt;strong&gt;"vhddrive:" &lt;/strong&gt;from now on.&lt;br /&gt;&lt;br /&gt;7 - In de Elevated CMD run the following:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;imagex /info V:\sources\install.wim&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;This will show you all the entries (or versions) available in the WIM-file; Hyper-V Server 2008 R2 has only one entry; it will have "index 1". No changes have been made yet.&lt;br /&gt;&lt;br /&gt;Remember that V: was assumed to be the drive letter of your DVD Drive (where the Windows Install disk lives).&lt;br /&gt;&lt;br /&gt;With the previously found index number, run the following:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;imagex /apply V:\sources\install.wim 1 vhddrive:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;This step takes a while, and will place a complete image of the Windows version you want to install into the VHD.&lt;br /&gt;&lt;br /&gt;8 - Boot files&lt;br /&gt;Let's copy the necessary boot file from the new VHD to the USB Drive:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;bcdboot vhddrive:\Windows /s U: /v&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;9&amp;nbsp;- Clean up&lt;br /&gt;You can now close the CMD where you ran BcdBoot.&lt;br /&gt;Go back to the CMD with DiskPart, en run:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;detach vdisk&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;"&gt;Exit&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;Close the CMD Window.&lt;br /&gt;&lt;br /&gt;Remove your Windows Install disk from the drive. It is no longer needed. The created VHD will be used for installing Windows.&lt;br /&gt;&lt;br /&gt;Reboot the machine, and make sure the FIRST boot device is the USB Drive. Windows may want to reboot a few times, and it would be annoying if it would boot into the wrong version.&lt;br /&gt;&lt;br /&gt;Boot into the USB Drive and see the magic happen.&lt;br /&gt;&lt;hr /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-2106091886664898879?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/2106091886664898879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=2106091886664898879&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/2106091886664898879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/2106091886664898879'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2010/03/running-windows-runtime-from-usb.html' title='Running Windows 7 / 2008 (runtime) off a USB Drive using a VHD'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_8QuMOYSBFtc/S5od6cc7MuI/AAAAAAAAABg/3ZUgoI0ZJ2g/s72-c/p3.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-9023426028106993393</id><published>2010-03-05T07:54:00.000+01:00</published><updated>2010-03-05T07:54:25.136+01:00</updated><title type='text'>Credibility</title><content type='html'>I was more than surprised to see someone disbelieving a rather very interesting post, with quality content, because he ONLY HAD 6 COMMENTS. Unbelievable but true. Credibility is rated by the number of comments on a post. This a particularly awkward for new posts, as by definition new posts have ZERO COMMENTS. Oh dear.... should we start commenting on our own posts in order to attract attention?&lt;br /&gt;&lt;br /&gt;Would the content of the comments matter?&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Great post!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;i&gt;by Adje&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Wonderfully put&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;i&gt;by Frank&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Experienced the very same thing!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;i&gt;by ScreenMan&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Are you kidding me?&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;i&gt;by TheDude&lt;/i&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-9023426028106993393?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/9023426028106993393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=9023426028106993393&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/9023426028106993393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/9023426028106993393'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2010/03/credibility.html' title='Credibility'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-1505962380632233637</id><published>2010-02-28T21:46:00.001+01:00</published><updated>2010-02-28T21:46:54.952+01:00</updated><title type='text'>Chrome doesn’t stack or tile in Windows 7</title><content type='html'>&lt;p&gt;Windows 7 has two features called &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Show windows side by side&lt;/li&gt;    &lt;li&gt;Show windows stacked&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;These can be reached by right-clicking the task-bar.&lt;/p&gt;  &lt;p&gt;Personally, I don’t really have a need for it, but as it’s there, I decided to have a go at it.&lt;/p&gt;  &lt;p&gt;So I opened some applications. Well, actually a few more than some: 35 to be exact. Unfair on Windows really, but it behaves remarkably well. With so many windows to tile or stack, the frames get of course very small, and they start overlapping. Which is curious, as they have not yet reached their resize limits!??!&lt;/p&gt;  &lt;p&gt;Of course, there’s also apps that don’t resize so far down when done manually. Like Yahoo Messenger for example. As is to be expected, they don’t tile or stack well (as they refuse to get that small).&lt;/p&gt;  &lt;p&gt;But what about Google Chrome? Manually it can be resized to any level; but when tiles or stacked, it doesn’t play ball. It refuses to budge even by 1 pixel. It simply remains sitting there…..&lt;/p&gt;  &lt;p&gt;Now why would that be? Anyone?&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-1505962380632233637?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/1505962380632233637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=1505962380632233637&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/1505962380632233637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/1505962380632233637'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2010/02/chrome-doesnt-stack-or-tile-in-windows.html' title='Chrome doesn’t stack or tile in Windows 7'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-1576866735159762967</id><published>2010-02-22T15:32:00.004+01:00</published><updated>2010-03-11T14:18:24.393+01:00</updated><title type='text'>Add VHD to Windows 7 boot menu</title><content type='html'>Nothing new here, and therefor short. It's mainly so I have this stored where I can easily reach it.&lt;br /&gt;(Content stolen from others)&lt;br /&gt;&lt;br /&gt;Here's how to add a VHD to Windows 7's boot menu.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Start &lt;b&gt;BCDEdit&lt;/b&gt; as &lt;b&gt;Administrator&lt;/b&gt;&lt;/li&gt;&lt;li&gt;Keep it simple: and copy an existing item (type this &lt;strong&gt;literally&lt;/strong&gt;, but choose a new name)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bcdedit /copy {current} /d "new name here"&lt;br /&gt;This will show you the newly created &lt;b&gt;GUID&lt;/b&gt;, which we use in the next commands.&lt;/li&gt;&lt;li&gt;Let the &lt;b&gt;BCD&lt;/b&gt; know which files to use (note the square brackets and colon for the drive letter)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bcdedit /set {new GUID} device vhd=[drive:]\&amp;lt;path to your vhd&amp;gt;\&amp;lt;your vhd&amp;gt;.vhd&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; bcdedit /set {new GUID} osdevice vhd=[drive:]\&amp;lt;path to your vhd&amp;gt;\&amp;lt;your vhd&amp;gt;.vhd&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Should you want to change the item's description:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Find the &lt;b&gt;GUID&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bcdedit /enum: &lt;/li&gt;&lt;li&gt;Change &lt;b&gt;description&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bcdedit /set {GUID} description "new description here"&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;For more information about the BCDEdit tool, read the &lt;a href="http://technet.microsoft.com/en-us/library/cc709667%28WS.10%29.aspx"&gt;article&lt;/a&gt; at TechNet&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-1576866735159762967?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/1576866735159762967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=1576866735159762967&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/1576866735159762967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/1576866735159762967'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2010/02/add-vhd-to-windows-7-boot-menu.html' title='Add VHD to Windows 7 boot menu'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-1163944445618180707</id><published>2010-02-22T15:17:00.005+01:00</published><updated>2010-02-22T15:37:48.925+01:00</updated><title type='text'>Install Windows 7/2008 on a VHD</title><content type='html'>Nothing new here, and therefor short. It's mainly so I have this stored where I can easily reach it.&lt;br /&gt;(Content stolen from others)&lt;br /&gt;&lt;br /&gt;Here's how to create a bootable VHD.&lt;br /&gt;&lt;div class="entry"&gt;&lt;div class="snap_preview"&gt;&lt;ul&gt;&lt;li&gt;Boot from DVD&lt;/li&gt;&lt;li&gt;When the question for the regional  settings appears, press &lt;b&gt;SHIFT-F10&lt;/b&gt;. This opens a command  prompt.&lt;/li&gt;&lt;li&gt;Start &lt;b&gt;DISKPART&lt;/b&gt;. With this Disk Partition Tool create a VHD file.&lt;/li&gt;&lt;li&gt;Enter: &lt;b&gt;CREATE VDISK FILE=&amp;lt;path to your vhd&amp;gt;\&amp;lt;your vhd&amp;gt;.vhd TYPE=EXPANDABLE  MAXIMUM=20000&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;This creates a VHD file with a default size of 20Gb ("FIXED" size is possible if you like). &lt;br /&gt;&lt;ul&gt;&lt;li&gt;Enter: &lt;b&gt;SELECT VDISK FILE=&amp;lt;path to your vhd&amp;gt;\&amp;lt;your vhd&amp;gt;.vhd&lt;/b&gt;&lt;/li&gt;&lt;li&gt;Enter: &lt;b&gt;ATTACH VDISK&lt;/b&gt;&lt;/li&gt;&lt;li&gt;Exit &lt;b&gt;DISKPART&lt;/b&gt; and exit the Command Prompt.&lt;/li&gt;&lt;li&gt;Continue the Windows installation and when the screen asks on what  partition to install Windows, you can now select the newly created VHD!  (Ignore any warnings).&lt;/li&gt;&lt;/ul&gt;The installation modifies the boot configuration, setting the new one as default.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For more information about the BCDEdit tool, read the &lt;a href="http://technet.microsoft.com/en-us/library/cc709667%28WS.10%29.aspx"&gt;article&lt;/a&gt;  at TechNet&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-1163944445618180707?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/1163944445618180707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=1163944445618180707&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/1163944445618180707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/1163944445618180707'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2010/02/install-windows-72008-on-vhd.html' title='Install Windows 7/2008 on a VHD'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-5692168167042696162</id><published>2010-02-22T12:38:00.001+01:00</published><updated>2010-02-22T15:35:12.751+01:00</updated><title type='text'>Windows 7: Auto elevating batchfiles</title><content type='html'>Having moved to Windows7&amp;nbsp;I found myself confronted with a small application no longer working: adding routes for VPN connection. Application wasn't mine, so recompiling not an option. What to do? Well, there used to be something called Batch files in Windows. They're still there.... As is PowerShell, but I'm not using that right now.&lt;br /&gt;&lt;br /&gt;So, Batch file it is. Got some code from a colleague to get me started, built on it, and ran it from another application I use: mRemote. Alas, no dice. The Batch file needs elevated permissions to start.&lt;br /&gt;&lt;br /&gt;There are several ways of doing that, depending on the context you're in, but it would be nice if it would elevate itself. So here's an example of how to do just that. The batch file checks if it has elevated rights, and when not, creates VBScript on the fly and lauches it. The VBScript calls the very same Batch file again with elevated permissions (you still get the prompt for permissions though).&lt;br /&gt;&lt;br /&gt;Now, when I forget to run mRemote in elevated mode, the batch file will elevate itself.&lt;br /&gt;&lt;br /&gt;The major problem I was/am facing doing this is the fact that it is rather difficult to pass parameters with spaces in it. Fact: I didn't manage. So I resolved to separate paramters with hashes (#) instead.&lt;br /&gt;&lt;br /&gt;Here's the code to do all this (I hope nothing got stripped out when posting this).&lt;br /&gt;(The interesting bit from elevation point of view are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;:testUAC&lt;/li&gt;&lt;li&gt;:doElevation&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;@echo off&lt;br /&gt;SetLocal enabledelayedexpansion&lt;br /&gt;&lt;br /&gt;rem --- Usage ---&lt;br /&gt;rem parameters must be separated by hash signs&lt;br /&gt;rem e.g.: My VPN#My Name#My Password#1&lt;br /&gt;rem Parameters:&lt;br /&gt;rem VPNNAME e.g. My VPN&lt;br /&gt;rem VPNUSERNAME e.g. erp234&lt;br /&gt;rem VPNPASSWORD e.g. xyz123&lt;br /&gt;rem NOPAUSE 0 / 1 ==&amp;gt; whether or not to pause at the end of the script&lt;br /&gt;&lt;br /&gt;rem --- Push directory ---&lt;br /&gt;rem In case we are called from withing other hosts&lt;br /&gt;cd /D "%~dp0" &lt;br /&gt;&lt;br /&gt;rem --- Deal with parameters --- &lt;br /&gt;for /f "tokens=1-5 delims=#" %%a in ("%*") do (&lt;br /&gt;set VPNNAME=%%a&lt;br /&gt;set VPNUSERNAME=%%b&lt;br /&gt;set VPNPASSWORD=%%c&lt;br /&gt;set NOPAUSE=%%d&lt;br /&gt;)&lt;br /&gt;:testUAC&lt;br /&gt;rem --- Test uac ---&lt;br /&gt;rem We assume %windir% environment variable exists&lt;br /&gt;rem Redirect error messages to NUL&lt;br /&gt;rem THIS WILL FAIL IF DIRECTORY ALREADY EXISTS.&lt;br /&gt;rem IS THERE A BETTER WAY OF CHECKING IF WE ARE ALREADY ELEVATED&lt;br /&gt;mkdir %windir%\uactest 2&amp;gt;nul&lt;br /&gt;if !ERRORLEVEL! == 1 (&lt;br /&gt;goto :doElevation&lt;br /&gt;) else (&lt;br /&gt;rd %windir%\uactest /s /q&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;rem --- START MAIN section ---&lt;br /&gt;&lt;br /&gt;:skipElevation&lt;br /&gt;&lt;br /&gt;rem --- Stop the VPN ---&lt;br /&gt;rem echo * Bestaande verbinding verbreken (indien aanwezig) : %VPNNAME%&lt;br /&gt;rem rasdial "%VPNNAME%" /disconnect&lt;br /&gt;rem echo.&lt;br /&gt;&lt;br /&gt;:startVPN&lt;br /&gt;rem --- Start the VPN ---&lt;br /&gt;echo * Starting VPN : %VPNNAME%&lt;br /&gt;rasdial "%VPNNAME%" %VPNUSERNAME% %VPNPASSWORD% &lt;br /&gt;echo.&lt;br /&gt;if !ERRORLEVEL! == 1 GOTO couldNotStartVPN&lt;br /&gt;&lt;br /&gt;rem Reset VPNIP&lt;br /&gt;set VPNIP=&lt;br /&gt;&lt;br /&gt;rem Reset ERRORLEVEL&lt;br /&gt;CD &amp;gt; NUL&lt;br /&gt;&lt;br /&gt;echo * Identifying received IP from started connection....&lt;br /&gt;&lt;br /&gt;ver | find "2003" &amp;gt; nul&lt;br /&gt;if !ERRORLEVEL! == 0 goto getVPNIP_2003&lt;br /&gt;&lt;br /&gt;ver | find "XP" &amp;gt; nul&lt;br /&gt;if !ERRORLEVEL! == 0 goto getVPNIP_XP&lt;br /&gt;&lt;br /&gt;ver | find "2000" &amp;gt; nul&lt;br /&gt;if !ERRORLEVEL! == 0 goto getVPNIP_2000&lt;br /&gt;&lt;br /&gt;ver | find "NT" &amp;gt; nul&lt;br /&gt;if !ERRORLEVEL! == 0 goto getVPNIP_NT&lt;br /&gt;&lt;br /&gt;rem --- Speed ---&lt;br /&gt;rem Reg is way faster than SystemInfo&lt;br /&gt;if exist %SystemRoot%\system32\reg.exe goto doReg&lt;br /&gt;if exist %SystemRoot%\system32\systeminfo.exe goto doSysInfo&lt;br /&gt;goto warnOSThenExit&lt;br /&gt;&lt;br /&gt;:doReg&lt;br /&gt;set vers=&lt;br /&gt;for /f "tokens=3*" %%i IN ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName ^| Find "ProductName"') DO set vers=%%i %%j&lt;br /&gt;echo %vers%&lt;br /&gt;goto continueOS&lt;br /&gt;&lt;br /&gt;:doSysInfo&lt;br /&gt;set vers=&lt;br /&gt;for /f "delims=: tokens=2" %%i IN ('systeminfo ^| find "OS Name"') DO set vers=%%i&lt;br /&gt;&lt;br /&gt;goto continueOS&lt;br /&gt;&lt;br /&gt;:continueOS&lt;br /&gt;echo %vers% | find "Windows 7" &amp;gt; nul&lt;br /&gt;if !ERRORLEVEL! == 0 goto getVPNIP_7&lt;br /&gt;&lt;br /&gt;echo %vers% | find "Windows Server 2008" &amp;gt; nul&lt;br /&gt;if !ERRORLEVEL! == 0 goto getVPNIP_2008&lt;br /&gt;&lt;br /&gt;echo %vers% | find "Windows Vista" &amp;gt; nul&lt;br /&gt;if !ERRORLEVEL! == 0 goto getVPNIP_VISTA&lt;br /&gt;&lt;br /&gt;goto warnOSThenExit&lt;br /&gt;&lt;br /&gt;rem Reset ERRORLEVEL&lt;br /&gt;CD &amp;gt; NUL&lt;br /&gt;&lt;br /&gt;:getVPNIP_nt&lt;br /&gt;goto warnOSThenExit&lt;br /&gt;&lt;br /&gt;:getVPNIP_2000&lt;br /&gt;goto warnOSThenExit&lt;br /&gt;&lt;br /&gt;:getVPNIP_XP&lt;br /&gt;rem Windows XP&lt;br /&gt;for /f "skip=3 tokens=3" %%a in ('netsh diag show ip Miniport*') do (&lt;br /&gt;set VPNIP=%%a&lt;br /&gt;GOTO createRoutes&lt;br /&gt;)&lt;br /&gt;GOTO couldNotGetVPNIP&lt;br /&gt;&lt;br /&gt;:getVPNIP_2003&lt;br /&gt;goto warnOSThenExit&lt;br /&gt;&lt;br /&gt;:getVPNIP_VISTA&lt;br /&gt;goto warnOSThenExit&lt;br /&gt;&lt;br /&gt;:getVPNIP_7&lt;br /&gt;rem Windows 7&lt;br /&gt;for /f "tokens=3" %%a in ('netsh interface ip show addresses "%VPNNAME%" ^| find "IP Address"') do (&lt;br /&gt;set VPNIP=%%a&lt;br /&gt;GOTO createRoutes&lt;br /&gt;)&lt;br /&gt;GOTO couldNotGetVPNIP&lt;br /&gt;&lt;br /&gt;:getVPNIP_2008&lt;br /&gt;goto warnOSThenExit&lt;br /&gt;&lt;br /&gt;:couldNotGetVPNIP&lt;br /&gt;echo ! Failed to identify IP address from connection.&lt;br /&gt;GOTO END&lt;br /&gt;&lt;br /&gt;:couldNotStartVPN&lt;br /&gt;echo ! Failed to start VPN : %VPNNAME%&lt;br /&gt;GOTO END &lt;br /&gt;&lt;br /&gt;:warnOSThenExit&lt;br /&gt;echo ! No implementation for your OS&lt;br /&gt;GOTO END&lt;br /&gt;&lt;br /&gt;:createRoutes&lt;br /&gt;echo * Routeringen worden aangelegt voor 'qqq'&lt;br /&gt;route add 'ip1' MASK 255.255.0.0 %VPNIP%&lt;br /&gt;route add 'ip2' MASK 255.255.0.0 %VPNIP%&lt;br /&gt;echo.&lt;br /&gt;&lt;br /&gt;:OK&lt;br /&gt;echo * Connection established : %VPNNAME%&lt;br /&gt;&lt;br /&gt;:END&lt;br /&gt;if !NOPAUSE! == 1 GOTO ENDNOPAUSE&lt;br /&gt;echo * This window may be closed&lt;br /&gt;pause&lt;br /&gt;&lt;br /&gt;:ENDNOPAUSE&lt;br /&gt;set VPNIP=&lt;br /&gt;set VPNNAME=&lt;br /&gt;set VPNUSERNAME=&lt;br /&gt;set VPNPASSWORD=&lt;br /&gt;set NOPAUSE=EndLocal&lt;br /&gt;&lt;br /&gt;exit&lt;br /&gt;&lt;br /&gt;rem --- elevation routine ---&lt;br /&gt;&lt;br /&gt;:doElevation&lt;br /&gt;set str_ElevName="%temp%\elevate.vbs"&lt;br /&gt;echo ' // On the fly created for elevating Batch files&amp;nbsp;&amp;gt; %str_ElevName%&lt;br /&gt;echo ' // (Should also work on other types) &amp;gt;&amp;gt; %str_ElevName%&lt;br /&gt;echo Set objShell = CreateObject("Shell.Application") &amp;gt;&amp;gt; %str_ElevName%&lt;br /&gt;echo Set objWshShell = WScript.CreateObject("WScript.Shell") &amp;gt;&amp;gt; %str_ElevName%&lt;br /&gt;echo Set objWshProcessEnv = objWshShell.Environment("PROCESS") &amp;gt;&amp;gt; %str_ElevName%&lt;br /&gt;echo strDir = "" ^&amp;amp; Wscript.Arguments(0) &amp;gt;&amp;gt; %str_ElevName%&lt;br /&gt;echo strApp = "" ^&amp;amp; Wscript.Arguments(1) &amp;gt;&amp;gt; %str_ElevName%&lt;br /&gt;echo strParam = "" &amp;gt;&amp;gt; %str_ElevName%&lt;br /&gt;echo For i = 3 to Wscript.Arguments.Count &amp;gt;&amp;gt; %str_ElevName%&lt;br /&gt;echo strParam = strParam ^&amp;amp; Wscript.Arguments(i-1) ^&amp;amp; " " &amp;gt;&amp;gt; %str_ElevName%&lt;br /&gt;echo next &amp;gt;&amp;gt; %str_ElevName%&lt;br /&gt;echo objShell.ShellExecute strApp, "" ^&amp;amp; strParam, strDir, "runas" &amp;gt;&amp;gt; %str_ElevName%&lt;br /&gt;start wscript //nologo "%temp%\elevate.vbs" "%cd%" "%~nx0" %*&lt;br /&gt;goto :ENDNOPAUSE&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-5692168167042696162?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/5692168167042696162/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=5692168167042696162&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/5692168167042696162'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/5692168167042696162'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2010/02/windows7-auto-elevating-batchfiles.html' title='Windows 7: Auto elevating batchfiles'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-1781169014679039045</id><published>2010-02-11T23:20:00.008+01:00</published><updated>2011-01-31T17:16:05.239+01:00</updated><title type='text'>Virtual PC on Windows 7 without hardware virtualization</title><content type='html'>(Yes, it can be done. It's simple too. Read on.)&lt;br /&gt;&lt;br /&gt;... I installed Windows7.... Office 2010 beta.... and some good oldies.....&lt;br /&gt;And then I wanted to use my Virtual Machines that I happened to use A LOT under windows XP. So I searched for Microsoft's Windows Virtual Machine, which offered me to download first XP Mode, and then Windows Virtual PC. Obedient as I am, I did so.&lt;br /&gt;&lt;br /&gt;It didn't work. It said I needed Hardware Virtualization. Fine! Opened the BIOS. No dice!&lt;br /&gt;I mean: no virtualization. Flashed the BIOS (one never knows, and one has to try). No dice!&lt;br /&gt;&lt;br /&gt;So here I was, stuck with an old T5500 Intel Processor on a HP nx9420 machine, with a nice modern Windows7 that can't run my old VMs.&lt;br /&gt;&lt;br /&gt;So, fed up as I was, I went to clean out some hard-disks (I needed the space for VHDs with Server 2008 R2 on it). And one has to pass the time somehow (like 2 kids don't keep me busy enough. Hah!). While browsing through my HardDisks I came across some old version of Virtual PC (64 bit SP1). I figured I'd give it ago (it really sounds like I was bored doesn't it?).&lt;br /&gt;&lt;br /&gt;Guess what: runs like a house on fire.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Of course, the web is full of stories that hardware virtualization is needed for the new Microsoft Virtual PC. What the web isn't full of, is the fact that the old Microsoft Virtual PC software still works. I'm happy again.....&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;If you need the old 2007 version, just respond to my blog (I still have the 32 bit version too).&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-1781169014679039045?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/1781169014679039045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=1781169014679039045&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/1781169014679039045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/1781169014679039045'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2010/02/virtual-pc-on-windows7-without-hardware.html' title='Virtual PC on Windows 7 without hardware virtualization'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-544585490050334112</id><published>2007-12-11T21:08:00.001+01:00</published><updated>2010-02-20T11:32:22.370+01:00</updated><title type='text'>Robin jumped.</title><content type='html'>He actually jumped. After weeks, no, months of not daring to, he finally jumped. And guess what, he actually likes it. Yes, he now also dares to go down the big slide, because falling in the water is no longer a problem. The swimming-pool has gotten a whole new dimension for our son. Well done Robin!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-544585490050334112?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/544585490050334112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=544585490050334112&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/544585490050334112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/544585490050334112'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2007/12/he-jumped.html' title='Robin jumped.'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-1238135883198010812</id><published>2007-11-28T01:09:00.001+01:00</published><updated>2010-02-20T11:32:53.159+01:00</updated><title type='text'>We needed to turn it back on.</title><content type='html'>It was a link... a hyperlink.... you know: those things you click on when you're browsing the Net. There's tons of them. The Net wouldn't exist without them. It's the oldest feature the Net has.  Should be the easiest too... it isn't always though.&lt;br /&gt;&lt;br /&gt;Being self-employed gets you around. So you get to see things. Here's a little story (non-fiction).&lt;br /&gt;&lt;br /&gt;First, it had to be turned off (disappear from view and source-code). It took some searching how best to achieve this without actually having to really remove the link (it was to be turned off only temporarily). After approx. 1 hour search and phone-calls, some testing at two levels, a mistake by the system-admins, redoing the action, and one more test, the link was indeed no longer visible. At modern IT-rates, it took some 2 hours in total to turn it off...&lt;br /&gt;&lt;br /&gt;...only to be turned on again 4 days later; it took another hour.&lt;br /&gt;&lt;br /&gt;And all this because of a fantastic Content Management System. Aaah, the wonderful world of IT.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-1238135883198010812?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/1238135883198010812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=1238135883198010812&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/1238135883198010812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/1238135883198010812'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2007/11/we-needed-to-turn-it-back-on.html' title='We needed to turn it back on.'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2901536678118207539.post-4105324015823044478</id><published>2007-11-28T00:40:00.001+01:00</published><updated>2010-02-20T11:33:13.687+01:00</updated><title type='text'>We went on holiday.</title><content type='html'>That is to say, we wanted to. And for that we needed a car (for those not in the know: our Vectra gave up the ghost on a trip to Germany a few years ago, leaving us with only the Corsa).&lt;br /&gt;&lt;br /&gt;So we rent one. We do this regularly, but don't usually travel abroad with it.... all the way to far-away land called The Black Forest. And wouldn't you know: it &lt;span style="font-style: italic;"&gt;snows&lt;/span&gt; over there!!&lt;br /&gt;&lt;br /&gt;And that's where the problem starts. We need tires that will allow us to legally drive around over there. These winter-tires exist for all types of cars; there are even all-year (all-weather) tires, that are allowed. But it's difficult to come by on rental cars. At least in Holland that is. Last year Avis couldn't deliver them at all no more, because we asked too late. This year we're renting from Hertz, and we asked for them a month in advance. Should be enough time one would think.....&lt;br /&gt;&lt;br /&gt;Here's what happened.&lt;br /&gt;We couldn't find the "winter-tires" option on the internet, so we just booked a car with regular tires, and called up for special tires. Well, we were really in the nick of time (yes, it seems to take a few weeks to arrange tires), but we "might not get them" for the car we booked. We were recommended to cancel the booking, and call international travel. We did, and yes, they could get us a car (not the one we wanted) with winter-tires; them tires costing us a whopping 20 euros plus VAT per day extra (we would be cheaper off buying them ourselves, and selling them afterwards). Considering this, we were recommended to perhaps rent a car for one day, drive it to Germany (just across the border), and rent a car there, as they presumably would have winter-tires on them anyway. Well they don't, because winter-tires are only mandatory in southern Germany. Back to square one. We (i.e. my wife) phoned around a lot, spend half a day on it, and ended up at..... Avis. Yes, you're right, the ones that couldn't deliver last year.&lt;br /&gt;&lt;br /&gt;And here we thought it would be easy enough to rent a car....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2901536678118207539-4105324015823044478?l=edwinroestenburg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edwinroestenburg.blogspot.com/feeds/4105324015823044478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2901536678118207539&amp;postID=4105324015823044478&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/4105324015823044478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2901536678118207539/posts/default/4105324015823044478'/><link rel='alternate' type='text/html' href='http://edwinroestenburg.blogspot.com/2007/11/we-went-on-holiday.html' title='We went on holiday.'/><author><name>Edwin Roestenburg</name><uri>http://www.blogger.com/profile/03395512179619991965</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://3.bp.blogspot.com/_8QuMOYSBFtc/S4WjZNCfSDI/AAAAAAAAAAs/NP7BsVxcing/S220/Edwin3.jpg'/></author><thr:total>0</thr:total></entry></feed>
