<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Remko Weijnen&#039;s Blog (Remko&#039;s Blog) &#187; Citrix</title> <atom:link href="http://www.remkoweijnen.nl/blog/topics/citrix/feed/" rel="self" type="application/rss+xml" /><link>http://www.remkoweijnen.nl/blog</link> <description>About Terminal Server, Citrix, Delphi and other stuff</description> <lastBuildDate>Tue, 31 Jan 2012 15:37:53 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.2.1</generator> <item><title>Harmony Client crashes upon exit</title><link>http://www.remkoweijnen.nl/blog/2012/01/31/harmony-client/</link> <comments>http://www.remkoweijnen.nl/blog/2012/01/31/harmony-client/#comments</comments> <pubDate>Tue, 31 Jan 2012 15:37:08 +0000</pubDate> <dc:creator>Remko</dc:creator> <category><![CDATA[Citrix]]></category> <category><![CDATA[Packaging]]></category> <category><![CDATA[Windows 2003]]></category> <category><![CDATA[ThinApp]]></category><guid isPermaLink="false">http://www.remkoweijnen.nl/blog/2012/01/31/harmony-client/</guid> <description><![CDATA[Today I was troubleshooting the application &#8220;Harmony Client&#8221; which crashed upon exiting: The application had been thinapped and the error only appeared when starting the thinapped version. Using Process Monitor I noticed that the application wrote logfiles to the C:\Temp\HarmonyClient\Log folder (which of course it shouldn&#8217;t write there.). 00.11:12:56.033 Log created on 31-01-2012 (c:\temp\Harmonyclient\Log\HMY_Client_03A2@server_20120131_111256.LOG) User [...]]]></description> <content:encoded><![CDATA[<p>Today I was troubleshooting the application &#8220;Harmony Client&#8221; which crashed upon exiting:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/image21.png" rel="lightbox" class="thickbox no_icon" title="HARMONY_Client.exe - Toepassingsfout"><img style="display: inline" title="HARMONY_Client.exe - Toepassingsfout" alt="Toepassingspop-up: HARMONY_Client.exe - Toepassingsfout : De instructie op 0x77e621b6 verwijst naar geheugen op 0x4b750000. Een lees- of schrijfbewerking op het geheugen is mislukt: | The memory could not be read." src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/image_thumb21.png" width="415" height="84" /></a></p><p>The application had been thinapped and the error only appeared when starting the thinapped version.</p><p><span id="more-2368"></span><p>Using Process Monitor I noticed that the application wrote logfiles to the C:\Temp\HarmonyClient\Log folder (which of course it shouldn&#8217;t write there.).</p><div class="dean_ch" style="white-space: wrap;">00.11:12:56.033 Log created on 31-01-2012 (c:\temp\Harmonyclient\Log\HMY_Client_03A2@server_20120131_111256.LOG) User name: testuser<br /> 00.11:13:04.423 00000318 TCOEventHandler &nbsp; EXCEPTION: Destroy eventhandler is called while client is still running. <br /> 00.11:13:04.424 00000318 TCOEventHandler &nbsp;.Destroy<br /> 00.11:13:04.424 00000318 TCOEventHandler &nbsp;.Destroy &#8230; Done<br /> 00.11:13:04.424 00000318 TCOEventHandler &nbsp; Client disconnected by user</div><p>My next step was to trace using the Thinapp Log Monitor but unfortunately the error doesn&#8217;t occur when tracing.</p><p>This makes me believe it&#8217;s a timing issue; upon exit the application is cleaning up memory (objects) but destroys a certain object (eventhandler) while it&#8217;s still being accessed.</p><p>Upon further inspection of the Process Monitor log I noticed access to a file called HARMONY_Client.exe.9e3c5c50.ini.inuse which was in the ThinApp SandBox (<em>%Local AppData%\ApplicationHistory\HARMONY_Client.exe.9e3c5c50.ini.inuse</em>).</p><p>The application creates this file when it&#8217;s started and when it exists it copies this to <em>HARMONY_Client.exe.9e3c5c50.ini</em>.</p><p>I deleted this file and this made the error go away. Perhaps this fault will surface again in the future, further testing will need to tell us.</p><p><strong><u>Workaround<br /> <br /></u></strong>Delete *.inuse from the SandBox, preferably using a (vbs) script in the thinapp package each time the app is launched.</p><p><strong><u>Solution<br /> <br /></u></strong>Contact Vendor and get them to fix their software and while they&#8217;re at it, have them fix access to things such as C:\Temp as well.</p> ]]></content:encoded> <wfw:commentRss>http://www.remkoweijnen.nl/blog/2012/01/31/harmony-client/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Bypassing RES/Appsense Application Security</title><link>http://www.remkoweijnen.nl/blog/2012/01/27/bypassing-res-application-security/</link> <comments>http://www.remkoweijnen.nl/blog/2012/01/27/bypassing-res-application-security/#comments</comments> <pubDate>Fri, 27 Jan 2012 15:15:38 +0000</pubDate> <dc:creator>Remko</dc:creator> <category><![CDATA[Citrix]]></category> <category><![CDATA[RES]]></category> <category><![CDATA[Windows 2003]]></category><guid isPermaLink="false">http://www.remkoweijnen.nl/blog/?p=2354</guid> <description><![CDATA[The video below shows a Proof of Concept of bypassing Application Security in RES Workspace Manager . Please note that at this time the code is not publicly available so please don&#8217;t ask for it. EDIT 2: I added a video that I received from someone who tried my Excel Sheet with AppSense Application Manager. [...]]]></description> <content:encoded><![CDATA[<p>The video below shows a Proof of Concept of bypassing Application Security in RES Workspace Manager .</p><p>Please note that at this time the code is not publicly available so please don&#8217;t ask for it.</p><p><strong>EDIT 2</strong>: I added a video that I received from someone who tried my Excel Sheet with AppSense Application Manager.</p><hr /><p><strong>EDIT:</strong> I wanted to clarify a couple of things regarding this post.</p><p>First of all I would like to explain why I wrote this code and why I choose to test it with RES WM.</p><p>I had the idea about this approach a long time ago but I never got around to actually do it. The main reason was that I needed to convert Delphi code to VBA and especially converting some Windows headers was a lot of work. Then suddenly I noticed that someone had already converted the headers, so I all I had to do was rewrite the code that used it to VBA.</p><p>The choice for RES was made because of two reasons:</p><ol><li>If you want to beat something, you want to beat the best and I most certainly consider RES WM to be one of the top products.</li><li>At the time I wrote the POC code I had access to an enviroment with RES in it.</li></ol><p>I would like to emphasize that RES contacted me very quickly after publishing this blog. I&#8217;ve had contact with RES and they showed a very constructive approach with their primary goal being a fix or guidance for their customers. Hats of to RES taking a constructive approach and I will be working together with RES on this issue.</p><p>Finally I would like to state that I didn&#8217;t expect this post to draw this much attention, if I did I would have probably taken another approach.</p><hr /><p>&nbsp;</p><p><span id="more-2354"></span></p><div id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:b589a7f7-312a-4fcc-8f47-3c2f1c8862c2" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"><object width="448" height="252" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/ZdEzV1R2yBs?hd=1" /><param name="wmode" value="transparent" /><embed width="448" height="252" type="application/x-shockwave-flash" src="http://www.youtube.com/v/ZdEzV1R2yBs?hd=1" wmode="transparent" /></object></div><p>&nbsp;</p><h3>Same demo but now with AppSense:</h3><div id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:621b380a-4f9f-43ba-becd-7f38384e55bd" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"><object width="448" height="252" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/UJvptlKxEEk?hd=1" /><param name="wmode" value="transparent" /><embed width="448" height="252" type="application/x-shockwave-flash" src="http://www.youtube.com/v/UJvptlKxEEk?hd=1" wmode="transparent" /></object></div> ]]></content:encoded> <wfw:commentRss>http://www.remkoweijnen.nl/blog/2012/01/27/bypassing-res-application-security/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>The case of the Slow Xerox Universal Print Driver</title><link>http://www.remkoweijnen.nl/blog/2012/01/04/the-case-of-the-slow-xerox-universal-print-driver/</link> <comments>http://www.remkoweijnen.nl/blog/2012/01/04/the-case-of-the-slow-xerox-universal-print-driver/#comments</comments> <pubDate>Wed, 04 Jan 2012 21:54:29 +0000</pubDate> <dc:creator>Remko</dc:creator> <category><![CDATA[Citrix]]></category> <category><![CDATA[General]]></category> <category><![CDATA[Windows 2003]]></category> <category><![CDATA[XenApp]]></category> <category><![CDATA[Xerox]]></category><guid isPermaLink="false">http://www.remkoweijnen.nl/blog/2012/01/04/the-case-of-the-slow-xerox-universal-print-driver/</guid> <description><![CDATA[Earlier this week I was asked to investigate a problem with the Xerox Universal Printer Driver. Users complained that printing to a Xerox printer was much slower than printing to an HP printer. I received a reference document from a user, a rather complex Excel sheet. When selecting multiple tabs it took almost a minute [...]]]></description> <content:encoded><![CDATA[<p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/image9.png" rel="lightbox" class="thickbox no_icon" title="Xerox Logo"><img style="display: inline; float: right" title="Xerox Logo" alt="Xerox Logo" align="right" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/image_thumb9.png" width="64" height="64" /></a>Earlier this week I was asked to investigate a problem with the Xerox Universal Printer Driver. Users complained that printing to a Xerox printer was much slower than printing to an HP printer.</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/image10.png" rel="lightbox" class="thickbox no_icon" title="Excel 2007 Icon"><img style="margin: 0px 9px 0px 0px; display: inline; float: left" title="Excel 2007 Icon" alt="Excel 2007 Icon" align="left" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/image_thumb10.png" width="67" height="65" /></a>I received a reference document from a user, a rather complex Excel sheet. When selecting multiple tabs it took almost a minute to generate a print preview in Excel 2007 running on Windows 2003 with XenApp 5.</p><p>I was aware of a bug in the Xerox Universal Driver where almost 9.000 files were copied into the user&#8217;s profile directory (I wrote about that in an <a  href="http://www.remkoweijnen.nl/blog/2011/02/08/the-case-of-the-citrix-ready-printer-driver/" target="_blank">earlier post</a>). But this seemed to be another problem.</p><p>&#160;</p><p><span id="more-2319"></span><p>I made a trace with Process Monitor while generating the print preview and this made clear that the driver tries to create the key <strong>HKLM\Software\Xerox</strong>. This is denied because a user has of course no permissions to write in HKLM:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/clip_image002.jpg" rel="lightbox" class="thickbox no_icon" title="Process Monitor"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Process Monitor" border="0" alt="Process Monitor Trace | HKLM\Software\Xerox | ACCESS DENIED" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/clip_image002_thumb.jpg" width="386" height="317" /></a></p><p>The Registry Summary shows us that the driver tries to access HKLM\Software\Xerox almost 8.000 times before finally giving up:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/clip_image0026.jpg" rel="lightbox" class="thickbox no_icon" title="Process Monitor"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Process Monitor" border="0" alt="Registry Summary | HKLM\Software\Xerox" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/clip_image0026_thumb.jpg" width="419" height="216" /></a></p><p>I changed the permissions on the Xerox key to see what the driver writes to this key. It creates a subkey with the SID of the User under HKLM\Software\Xerox\V5.0\Low.</p><p>Then it gives the user special permissions on this key and subkeys so the user is allowed to write there.</p><p>Finally it stores a few settings in that key:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/clip_image0028.jpg" rel="lightbox" class="thickbox no_icon" title="Registry Editor"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Registry Editor" border="0" alt="HKLM\Software\Xerox" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2012/01/clip_image0028_thumb.jpg" width="417" height="317" /></a></p><p><img style="margin: 0px 7px 0px 0px; display: inline; float: left" align="left" src="http://farm1.staticflickr.com/113/282707058_02305d3cce_z.jpg?zz=1" width="95" height="84" />This looks like a serious design flaw because not only is a standard user not allowed to create keys under the HKLM hive but it also means that user settings are stored on a single machine and are not roaming with the user.</p><p>The good news was that the time to generate the print preview went back to around 4 seconds which is acceptable considering the complexity of the reference Excel sheet.</p><p>I tested in total 3 versions of the Xerox Universal Print Driver and they all exhibited this particular issue:</p><ul><li>5.185.42.0N 2011.03.02</li><li>5.216.12.0N 2011.06.10</li><li>5.246.7.0 2011.12.07</li></ul> ]]></content:encoded> <wfw:commentRss>http://www.remkoweijnen.nl/blog/2012/01/04/the-case-of-the-slow-xerox-universal-print-driver/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>NTVDM encountered a hard error</title><link>http://www.remkoweijnen.nl/blog/2011/12/14/ntvdm-encountered-a-hard-error/</link> <comments>http://www.remkoweijnen.nl/blog/2011/12/14/ntvdm-encountered-a-hard-error/#comments</comments> <pubDate>Wed, 14 Dec 2011 20:41:22 +0000</pubDate> <dc:creator>Remko</dc:creator> <category><![CDATA[C++]]></category> <category><![CDATA[Citrix]]></category> <category><![CDATA[Terminal Server]]></category> <category><![CDATA[Windows 2003]]></category> <category><![CDATA[DOS]]></category><guid isPermaLink="false">http://www.remkoweijnen.nl/blog/?p=2254</guid> <description><![CDATA[Today I troubleshooted an old DOS application that needed to run on a 32 bit Citrix XenApp Server. The last time I saw an actual DOS application in a production environment must be years ago. When starting the application, the WOW subsystem (NTVDM) crashed with the message: &#8220;NTVM encountered a hard error.&#8221;: After spending some [...]]]></description> <content:encoded><![CDATA[<p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image7.png" rel="lightbox" class="thickbox no_icon" title="MS-Dos Logo"><img style="margin: 0px 3px 0px 0px; display: inline; float: left" title="MS-Dos Logo" alt="MS-Dos Logo" align="left" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image_thumb7.png" width="74" height="82" /></a>Today I troubleshooted an old DOS application that needed to run on a 32 bit Citrix XenApp Server. The last time I saw an actual DOS application in a production environment must be years ago.</p><p>When starting the application, the WOW subsystem (NTVDM) crashed with the message: &#8220;NTVM encountered a hard error.&#8221;:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image8.png" rel="lightbox" class="thickbox no_icon" title="ntvdm.exe - System Error"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ntvdm.exe - System Error" border="0" alt="NTVDM encoutered a hard error" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image_thumb8.png" width="198" height="104" /></a></p><p>After spending some time troubleshooting I remembered a similar issue from a few years ago where a DOS application worked fine from the Console but refused to work from an RDP or ICA session.</p><p><span id="more-2254"></span><p>And indeed the application works perfectly when run from the Console but not from a Console <u>session</u>. I noticed that the application switched to full screen mode after it was launched (even when I set it to Windowed mode) and presumably this is why ntvdm errors: full-screen mode is disallowed for DOS apps in RDP (and ICA) sessions as documented in <a  href="http://support.microsoft.com/?kbid=192190" target="_blank">Q192190</a>.</p><p>I looked for a way to force the application to run in windowed mode but I was unable to find such a solution. So I decided to test the application in <a  href="http://sourceforge.net/projects/dosbox/" target="_blank">DOSBox</a>, an x86 PC emulator.</p><p>And that worked perfectly, no changes were needed at all to make the application run.</p><p>As an added bonus, DOSBox takes care of typical issues with DOS applications running on Citrix XenApp such as <a  href="http://support.citrix.com/article/CTX846521" target="_blank">keyboard polling and 100% cpu usage</a>.</p><p>I was even more impressed that the application <strong>runs fine with DOSBox on my Windows 7 64 bit machine</strong>!</p><p>There is one thing I didn&#8217;t like though, DOSBox always shows a Splashscreen that fades in and out:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image9.png" rel="lightbox" class="thickbox no_icon" title="image"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image_thumb9.png" width="419" height="277" /></a></p><p>This is typically something that is not desirable on a XenApp (or RDS) environment because it causes many unnecessary screen updates. This may be a non issue on a fast LAN but on a slower WAN or high latency connection it may matter. Do how do we get rid of it?</p><p>There is no commandline argument or config setting that disables the splash so I figured that my only option would be to compile the DOSBox source and leave out the splash screen.</p><p>So I downloaded the source files from the sourceforge project page and launched Visual Studio 2010.</p><p>The Splashscreen is in sdlmain.cpp but I noticed this comment:</p><div class="dean_ch" style="white-space: wrap;"><span class="coMULTI">/* Please leave the Splash screen stuff in working order<br /> &nbsp; &nbsp;in DOSBox. We spend a lot of time making DOSBox. */</span></div><p>This presented me with a dilemma: I really think the creators deserve their credit but at the same time I want to get rid of the splash.</p><p>So I decided to change the code in a way that the Splash screen is shown when run from the Console but not when run from an RDP or ICA session. This change was very easy, I surrounded the Splash screen code with a conditional statement:</p><div class="dean_ch" style="white-space: wrap;"><span class="coMULTI">/* We will ignore the splashscreen when in a remote session */</span><br /> &nbsp; &nbsp;<br /> <span class="kw1">if</span> <span class="br0">&#40;</span>!GetSystemMetrics<span class="br0">&#40;</span>SM_REMOTESESSION<span class="br0">&#41;</span><span class="br0">&#41;</span><br /> <span class="br0">&#123;</span><br /> &nbsp; &nbsp; <span class="co1">// Splash screen code</span><br /> <span class="br0">&#125;</span></div><p>In order to compile the code with Visual Studio I followed the <a  href="http://www.dosbox.com/wiki/Building_DOSBox_with_Visual_C_2008_Express" target="_blank">Building DOSBox with Visual C 2008 Express</a> article from the Wiki.</p><p>Below you will find two downloads:</p><ul><li>A binary package, containing my compiled DOSBox.exe and it&#8217;s dependancies.</li><li>A source code package, containing the modified source and the SDL Development Libraries. The modified source is licensed under the <a  href="http://www.gnu.org/copyleft/gpl.html" target="_blank">GNU GPL license</a>.</li></ul><p>If you are going to use DOSBox I highly encourage you to make a donation to <a  href="http://sourceforge.net/donate/index.php?group_id=52551" target="_blank">Support the DOSBox project</a>.</p><p>&#160;</p><p>A few other causes for the &#8220;NTVM encountered a hard error&#8221; message may be:</p><ul><li><font color="#35383d">The %TEMP% or %TMP% variable point to a directory that is not in a short (8.3) format. See also <a  href="http://support.citrix.com/article/CTX110996" target="_blank">CTX110996</a>.</font></li><li>Error message when you run a 16-bit program in Windows Server 2003: &quot;NTVDM has encountered a hard error<font color="#35383d">&#8221; (<a  href="http://support.microsoft.com/kb/937932" target="_blank">Hotfix KB937932</a>).</font></li><li><font color="#35383d">Check that HKLM\System\CurrentControlSet\Control\WOW\DisallowedPolicyDefault is set to 0</font></li><li><font color="#35383d">Check that HKLM\SYSTEM\CurrentControlSet\Control\VirtualDeviceDrivers\VDD doesn&#8217;t contain non existing files.</font></li></ul><ul><a  class="downloadlink" href="http://www.remkoweijnen.nl/blog/download/DOSBox-0.74-Bin.zip" title="Version0.74 downloaded 23 times">DOSBox 0.74 (23)</a></ul><ul><a  class="downloadlink" href="http://www.remkoweijnen.nl/blog/download/DOSBox-0.74-Src.zip" title="Version0.74 downloaded 8 times">DOSBox 0.74 Source Code (8)</a></ul> ]]></content:encoded> <wfw:commentRss>http://www.remkoweijnen.nl/blog/2011/12/14/ntvdm-encountered-a-hard-error/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Citrix online plug-in received a corrupt ICA File</title><link>http://www.remkoweijnen.nl/blog/2011/12/13/citrix-online-plug-in-received-a-corrupt-ica-file/</link> <comments>http://www.remkoweijnen.nl/blog/2011/12/13/citrix-online-plug-in-received-a-corrupt-ica-file/#comments</comments> <pubDate>Tue, 13 Dec 2011 09:58:24 +0000</pubDate> <dc:creator>Remko</dc:creator> <category><![CDATA[Citrix]]></category> <category><![CDATA[script]]></category><guid isPermaLink="false">http://www.remkoweijnen.nl/blog/2011/12/13/citrix-online-plug-in-received-a-corrupt-ica-file/</guid> <description><![CDATA[I was testing a Script I wrote to launch a Citrix XenApp session using the Ica Client Object. Typical code to do this may look like this: Const cHttpBrowser = &#34;someurl.local&#34; Const cColorDepth = 4 &#8216; Create the ICA Client Object Dim objIca : Set objIca = CreateObject(&#34;Citrix.IcaClient.2&#34;) &#8216; Set Credentials objIca.Username = &#34;JohnDoe&#34; objIca.SetProp [...]]]></description> <content:encoded><![CDATA[<p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image4.png" rel="lightbox" class="thickbox no_icon" title="image"><img style="display: inline; float: left" title="image" alt="image" align="left" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image_thumb4.png" width="38" height="35" /></a>I was testing a Script I wrote to launch a Citrix XenApp session using the Ica Client Object. Typical code to do this may look like this:</p><div class="dean_ch" style="white-space: wrap;">Const cHttpBrowser = &quot;someurl.local&quot;<br /> Const cColorDepth = 4</p><p>&#8216; Create the ICA Client Object<br /> Dim objIca : Set objIca = CreateObject(&quot;Citrix.IcaClient.2&quot;)</p><p>&#8216; Set Credentials<br /> objIca.Username = &quot;JohnDoe&quot;<br /> objIca.SetProp &quot;ClearPassword&quot;, &quot;Secret01&quot;<br /> objIca.Domain = &quot;CONTOSO&quot;</p><p>&#8216; Connection Settings<br /> objIca.BrowserProtocol = &quot;HTTPonTCP&quot;<br /> objIca.TransportReconnectEnabled = True<br /> objIca.HttpBrowserAddress = cHttpBrowser</p><p>&#8216; Session Settings<br /> objIca.Address = &quot;MyApp&quot;<br /> objIca.Application = &quot;MyApp&quot;<br /> objIca.DesiredColor = cColorDepth<br /> objIca.ScreenPercent = 0 &#8216; Full Screen<br /> objIca.DesiredHRes = 0<br /> objIca.DesiredVRes = 0<br /> objIca.Launch = True</p><p>&#8216; Connect<br /> objIca.Connect</div><p>On my testmachine it ran nicely but on a customer machine the script failed with the error 2312 &#8220;<em>The Citrix online plug-in received a corrupt ICA File. The ICA File has no [ApplicationServer] section</em>&#8220;:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/SNAGHTML108b7fef.png" rel="lightbox" class="thickbox no_icon" title="Error number 2312"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Error number 2312" border="0" alt="The Citrix online plug-in received a corrupt ICA File. The ICA File has no [ApplicationServer] section" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/SNAGHTML108b7fef_thumb.png" width="419" height="98" /></a></p><p><span id="more-2242"></span><p>I couldn&#8217;t find any errors in my script so I fired up Process Monitor and noticed that the Ica Client Object creates a temporary .ica file in the %temp% folder. When it tried to write to this file this fails because access is denied:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/SNAGHTML10912948.png" rel="lightbox" class="thickbox no_icon" title="Process Monitor"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Process Monitor" border="0" alt="Process Monitor | ACCESS DENIED | temp folder | temporary ICA file" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/SNAGHTML10912948_thumb.png" width="419" height="265" /></a></p><p>I Checked the temporary .ica file and it was empty (0 bytes). Then I used the Stack View option from Process Monitor on the first ACCESS DENIED event:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image5.png" rel="lightbox" class="thickbox no_icon" title="Event Properties"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Event Properties" border="0" alt="Process Monitor | Stack View" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image_thumb5.png" width="419" height="286" /></a></p><p>From the stack we can see that fltMgr.sys is the last to touch the file (stack is from bottom to top). fltMgr is the File System Filter Driver which makes it likely that the Virus Scanner is blocking access. So I checked the Anti Virus log, McAfee VirusScan in my case:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image6.png" rel="lightbox" class="thickbox no_icon" title="image"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/12/image_thumb6.png" width="419" height="42" /></a></p><p>The text is in Dutch, it says: Blocked by the access rule: maximum Anti-Spyware: prevent script execution from the temp folder.</p><p>So McAfee considers the .ica a script since it&#8217;s created by the process cscript.exe.</p><p>Unfortunately the Ica Client Object doesn&#8217;t offer a method or property to change the folder where the temporary ica file is created. I decided to have look at Wfica.ocx with Ida Pro and noticed that the <a  href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa364992(v=vs.85).aspx" target="_blank">GetTempPath</a> and <a  href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa364991(v=VS.85).aspx" target="_blank">GetTempFilename</a> API&#8217;s are used to assemble the filepath.</p><p>In the remarks section of the GetTempPath documentation on MSDN states that it looks first to the %TMP% environment variable.</p><p>So we can easily workaround this issue by changing the %TMP% variable before we run our script:</p><div class="dean_ch" style="white-space: wrap;">rem change TMP to the current folder<br /> Set TMP=%CD%<br /> cscript OurScript.vbs</div> ]]></content:encoded> <wfw:commentRss>http://www.remkoweijnen.nl/blog/2011/12/13/citrix-online-plug-in-received-a-corrupt-ica-file/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Extremely slow Virtual Machines on HP Smart Array P410</title><link>http://www.remkoweijnen.nl/blog/2011/05/02/extremely-slow-virtual-machines-on-hp-smart-array-p410/</link> <comments>http://www.remkoweijnen.nl/blog/2011/05/02/extremely-slow-virtual-machines-on-hp-smart-array-p410/#comments</comments> <pubDate>Mon, 02 May 2011 12:15:50 +0000</pubDate> <dc:creator>Remko</dc:creator> <category><![CDATA[Citrix]]></category> <category><![CDATA[VMWare]]></category> <category><![CDATA[HP]]></category><guid isPermaLink="false">http://www.remkoweijnen.nl/blog/2011/05/02/extremely-slow-virtual-machines-on-hp-smart-array-p410/</guid> <description><![CDATA[I was deploying virtualized Citrix XenApp Servers on HP BL460c G6 servers and somehow the storage (direct attached) responded very slowly. I had expected reduced performance (see my earlier post) since I didn&#8217;t have the&#160; Battery Backed Write Cache module installed. I did order them but had to start deployment before they arrived. I did [...]]]></description> <content:encoded><![CDATA[<p>I was deploying virtualized Citrix XenApp Servers on HP BL460c G6 servers and somehow the storage (direct attached) responded very slowly.</p><p>I had expected reduced performance (see <a  href="http://www.remkoweijnen.nl/blog/2010/10/16/slow-power-on-and-storage-operations-with-hp-smart-array-p410i-controller-on-vmware-vsphere-4-0/" target="_blank">my earlier post</a>) since I didn&#8217;t have the&#160; Battery Backed Write Cache module installed. <br />I did order them but had to start deployment before they arrived.</p><p>I did not however expect such an extreme bad performance. Deployment took ages or sometimes failed completely and when logging in to a VM it responded very sluggish.</p><p><strong><u>Disk Latency</u></strong></p><p>I looked in the vSphere console what the Disk Latency was. Latency under 10ms is usually considered good while a latency between 10 and 20ms is a potential performance problem.</p><p>I was shocked to notice that the Disk Latency was much higher with peaks toward 2.000 ms (2 seconds!):</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/DiskLatency.png" rel="lightbox" class="thickbox no_icon" title="DiskLatency"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="DiskLatency" border="0" alt="DiskLatency" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/DiskLatency_thumb.png" width="362" height="243" /></a></p><p>&#160;</p><p><span id="more-1719"></span><p>At the same time the transfer rates were very low:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/DiskKbps.png" rel="lightbox" class="thickbox no_icon" title="DiskKbps"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="DiskKbps" border="0" alt="DiskKbps" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/DiskKbps_thumb.png" width="367" height="248" /></a></p><p>&#160;</p><p><strong><u>CPU Ready time</u></strong></p><p>A look at the CPU Ready and CPU Wait counters was the final confirmation that storage was the bottleneck.</p><p>To view these counters, select the VM in question and go to the Performance Tab and click Advanced:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image.png" rel="lightbox" class="thickbox no_icon" title="image"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image_thumb.png" width="244" height="50" /></a></p><p>Then add the counters:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/SNAGHTML15276d9f.png" rel="lightbox" class="thickbox no_icon" title="SNAGHTML15276d9f"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML15276d9f" border="0" alt="SNAGHTML15276d9f" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/SNAGHTML15276d9f_thumb.png" width="244" height="232" /></a></p><p>&#160;</p><p>These counters indicate that the CPU is waiting for something (the storage in this case). <br />You will want these numbers to be as low as possible and they are very high here:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image1.png" rel="lightbox" class="thickbox no_icon" title="image"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image_thumb1.png" width="372" height="249" /></a></p><p><strong><u> <br />Console Errors</u></strong></p><p>On the VMWare console I noticed the following errors:</p><ul><li>scsi_cmd_alloc returned NULL!</li><li>WARNING: NMP: nmp_DeviceRetryCommand</li><li>WARNING: NMP: nmp_DeviceAttemptFailover</li></ul><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image2.png" rel="lightbox" class="thickbox no_icon" title="image"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image_thumb2.png" width="372" height="124" /></a></p><p>I went back from deploying multiple machines at once to just one but this didn&#8217;t improve the performance at all.</p><p>Using the error messages above I found this knowledge base article from Hewlett Packard: <a  href="http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=c01832427&#038;lang=en&#038;cc=us&#038;taskId=101&#038;prodSeriesId=3884082&#038;prodTypeId=15351" target="_blank">To Obtain Optimal Disk Subsystem Performance on ProLiant G6 Servers Configured with Smart Array P410i/P410/P411/P412/P212/P712m Controllers Running VMware</a>.</p><p>The article states: <em>When the Battery Backed Write Cache is not included in the configuration, even moderate disk I/O can negatively impact server performance.</em></p><p>In my opinion the article actually says: performance without the battery backed cache module is is absolutely horrible and there is no way you can successfully run any Virtual Machine on the hardware without it!</p><p>And then, to my great relief,&#160; the upgrade hardware (including the BBWC) was delivered. So I immediately built in the BBWC because I wanted to include the results in this post:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image3.png" rel="lightbox" class="thickbox no_icon" title="image"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image_thumb3.png" width="421" height="169" /></a></p><p>After placing the BBWC module it will not be activated until the battery has been sufficiently charged:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image4.png" rel="lightbox" class="thickbox no_icon" title="image"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image_thumb4.png" width="400" height="88" /></a></p><p><strong><u> <br />Results</u></strong></p><p>And then the results are amazing:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image5.png" rel="lightbox" class="thickbox no_icon" title="image"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image_thumb5.png" width="244" height="165" /></a></p><p>And finally a successful deployment:</p><p><a  href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image6.png" rel="lightbox" class="thickbox no_icon" title="image"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/05/image_thumb6.png" width="411" height="270" /></a></p><p>Especially the time needed for restoring the base image went down a lot (this includes not only the actual restore but also sysprep, network config and several reboots).</p><p><strong><u></u><p>Related links</p><p> </strong></p><ul><li><a  href="http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=c01832427&#038;lang=en&#038;cc=us&#038;taskId=101&#038;prodSeriesId=3884082&#038;prodTypeId=15351" target="_blank">To Obtain Optimal Disk Subsystem Performance on ProLiant G6 Servers Configured with Smart Array P410i/P410/P411/P412/P212/P712m Controllers Running VMware</a></li><li><a href="http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&amp;docType=kc&amp;externalId=1036961&amp;sliceId=1&amp;docTypeID=DT_KB_1_1&amp;dialogID=178739822&amp;stateId=0 0 178741131" target="_blank">Slow virtual machine storage when using HP Smart Array P410 with ESX 3.5</a> (also on 4.1).</li><li><a  href="http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&#038;cmd=displayKC&#038;externalId=1018794" target="_blank">Slow power on and storage operations with the HP Smart Array P410i controller</a></li><li><a  href="http://h10010.www1.hp.com/wwpc/uk/en/sm/WF06c/A1-329290-332469-3965891-3965891-434812-3890508.html" target="_blank">HP 512MB P-Series Battery Backed Write Cache Upgrade</a></li></ul> ]]></content:encoded> <wfw:commentRss>http://www.remkoweijnen.nl/blog/2011/05/02/extremely-slow-virtual-machines-on-hp-smart-array-p410/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>The Case of the Citrix Ready Printer Driver</title><link>http://www.remkoweijnen.nl/blog/2011/02/08/the-case-of-the-citrix-ready-printer-driver/</link> <comments>http://www.remkoweijnen.nl/blog/2011/02/08/the-case-of-the-citrix-ready-printer-driver/#comments</comments> <pubDate>Tue, 08 Feb 2011 20:47:44 +0000</pubDate> <dc:creator>Remko</dc:creator> <category><![CDATA[Citrix]]></category> <category><![CDATA[PowerShell]]></category> <category><![CDATA[Terminal Server]]></category><guid isPermaLink="false">http://www.remkoweijnen.nl/blog/?p=1402</guid> <description><![CDATA[I had a very interesting issue today on a new Citrix XenApp 5 farm. We went into production yesterday and we noticed a number of issues: Printing in general was slow, especially when a user connects to a printer for the first time. User Profiles were rapidly growing in size (from the expected 1-2 MB [...]]]></description> <content:encoded><![CDATA[<p>I had a very interesting issue today on a new Citrix XenApp 5 farm. We went into production yesterday and we noticed a number of issues:</p><ul><li><span style="color: #35383d;">Printing in general was slow, especially when a user connects to a printer for the first time.</span></li><li>User Profiles were rapidly growing in size (from the expected 1-2 MB to over 40 MB).</li><li>Logons took much longer then in the testing period (and since we use a Full Screen Desktop the user doesn&#8217;t see any progress).</li><li>Performance monitoring showed CPU spikes in Word, Excel and IE processes.</li></ul><p><span style="color: #4c4c4c;">I took a look at the profiles first and noticed that the size growth was due to a Xerox subfolder in %APPDATA%:<br /> <span id="more-1402"></span></span></p><p><a  rel="lightbox" href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/02/image2.png" class="thickbox no_icon" title="image"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/02/image_thumb2.png" border="0" alt="image" width="327" height="378" /></a></p><p>An even bigger problem is the huge amount of files in this folder (almost 9000) which of course causes the delay in the logon (while the server is loading the profile).</p><p>This is very bad considering that this driver, the Xerox Global Print Driver is advertised by Xerox as the Terminal Server/Citrix ready printer driver!</p><p>What makes it even worse is that the driver exhibiting this bug, is still the one offered for download on the <a  href="http://www.support.xerox.com/support/global-printer-driver/downloads/enus.html?operatingSystem=wins2003&#038;fileLanguage=en" target="_blank">Xerox Site</a>.</p><p>For the record: I found this bug in version 5.185.19 dated oct. 14, 2010 in the PCL5 and PCL6 versions for both x86 and x64.</p><p>The good news is that I found a newer version that was linked on the Xerox forum, version 5.185.32 dated jan. 5, 2011.</p><p>I tested this version and the bug was fixed there, I cannot yet tell if the CPU Spikes issue was also fixed.</p><p>Here are the links:</p><ul><li><a  href="http://www.support.xerox.com/support/_all-products/file-download/enus.html?contentId=114411" target="_blank">Xerox Global Print Driver x86 PCL5</a></li><li><a  href="http://www.support.xerox.com/support/_all-products/file-download/enus.html?contentId=114412" target="_blank">Xerox Global Print Driver x64 PCL5</a></li><li><a  href="http://www.support.xerox.com/support/_all-products/file-download/enus.html?contentId=114415" target="_blank">Xerox Global Print Driver x86 PCL6</a></li><li><a  href="http://www.support.xerox.com/support/_all-products/file-download/enus.html?contentId=114416" target="_blank">Xerox Global Print Driver x64 PCL6</a></li></ul><p>But after installing this driver we also need to cleanup the (roaming) profiles to get rid of the Xerox folder.</p><p>I wrote a very simple PowerShell script for that:</p><div class="dean_ch" style="white-space: wrap;"><span class="re3">$Share</span> = <span class="st0">&quot;\\ADNRD01\TSProfiles$&quot;</span><br /> <span class="re3">$Xerox</span> = <span class="st0">&quot;\Application Data\Xerox&quot;</span></p><p><span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re3">$Folder</span> <span class="kw1">in</span> <span class="kw4">gci</span> <span class="re3">$Share</span><span class="br0">&#41;</span><br /> <span class="br0">&#123;</span><br /> &nbsp; <span class="re3">$Path</span> = <span class="re4"><span class="br0">&#91;</span><span class="kw3">System</span>.<span class="kw3">String</span><span class="br0">&#93;</span></span>::<span class="me2">Concat</span><span class="br0">&#40;</span><span class="re3">$Folder</span>.<span class="me1">FullName</span>, <span class="re3">$Xerox</span><span class="br0">&#41;</span><br /> &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">Test-<span class="re1">Path</span></span> <span class="re3">$Path</span><span class="br0">&#41;</span><br /> &nbsp; <span class="br0">&#123;</span><br /> &nbsp; &nbsp; <span class="re0">Remove-<span class="re1">Item</span></span> <span class="re3">$Path</span> <span class="re2">-Recurse</span> <span class="re2">-Force</span><br /> &nbsp; <span class="br0">&#125;</span><br /> <span class="br0">&#125;</span></div> ]]></content:encoded> <wfw:commentRss>http://www.remkoweijnen.nl/blog/2011/02/08/the-case-of-the-citrix-ready-printer-driver/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>PowerShell Script to add reboot scheduled task for Citrix</title><link>http://www.remkoweijnen.nl/blog/2011/01/31/powershell-script-to-add-reboot-scheduled-task-for-citrix/</link> <comments>http://www.remkoweijnen.nl/blog/2011/01/31/powershell-script-to-add-reboot-scheduled-task-for-citrix/#comments</comments> <pubDate>Mon, 31 Jan 2011 21:53:47 +0000</pubDate> <dc:creator>Remko</dc:creator> <category><![CDATA[Citrix]]></category> <category><![CDATA[PowerShell]]></category><guid isPermaLink="false">http://www.remkoweijnen.nl/blog/?p=1381</guid> <description><![CDATA[I wanted to create a Scheduled Task on my Citrix Servers to have the reboot every other night. The idea is that half of the servers will reboot in a night and the other half the following night. The TSSHUTDN tool is handy since it can issue a warning to logged on users, log them [...]]]></description> <content:encoded><![CDATA[<p>I wanted to create a Scheduled Task on my Citrix Servers to have the reboot every other night.</p><p>The idea is that half of the servers will reboot in a night and the other half the following night.</p><p>The <a  href="http://support.microsoft.com/kb/320188" target="_blank">TSSHUTDN</a> tool is handy since it can issue a warning to logged on users, log them out after a certain period and finally issue the reboot.</p><p>Since I needed to add a scheduled task to many servers I wanted to do this with a script.</p><p>WMI Exposes the <a  href="http://msdn.microsoft.com/en-us/library/aa394399(v=VS.85).aspx" target="_blank">Win32_ScheduledJob</a> Class and it&#8217;s <a  href="http://msdn.microsoft.com/en-us/library/aa389389(v=vs.85).aspx" target="_blank">Create Method</a>.</p><p><span id="more-1381"></span>The parameters, especially StartTime, are constructed very odly and I can never remember them.</p><p>So I wrote a very simple wrapper in PowerShell to make it a little easier for the next time:</p><div class="dean_ch" style="white-space: wrap;"><span class="co1"># Weekdays</span><br /> <span class="re3">$Mo</span> = <span class="nu0">1</span> ; <span class="re3">$Tu</span> = <span class="nu0">2</span> ; <span class="re3">$We</span> = <span class="nu0">4</span> ; <span class="re3">$Th</span> = <span class="nu0">8</span> ; <span class="re3">$Fr</span> = <span class="nu0">16</span> ; <span class="re3">$Sa</span> = <span class="nu0">32</span> ; <span class="re3">$Su</span> = <span class="nu0">64</span></p><p><span class="co1"># Get Time Bias</span><br /> <span class="re3">$Bias</span> = <span class="re3">$Bias</span> = <span class="st0">&quot;{0:D3}&quot;</span> <span class="re2">-f</span> <span class="re4"><span class="br0">&#91;</span><span class="kw3">int</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="kw3">System</span>.<span class="me1">TimeZoneInfo</span><span class="br0">&#93;</span></span>::<span class="me2">Local</span>.<span class="me1">BaseUtcOffset</span>.<span class="me1">TotalMinutes</span></p><p><span class="co1"># Get Correct Sign</span><br /> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re3">$Bias</span> <span class="re2">-gt</span> <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re3">$Sign</span> = <span class="st0">&quot;+&quot;</span> <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span> <span class="re3">$Sign</span> =<span class="st0">&quot;-&quot;</span> <span class="br0">&#125;</span></p><p><span class="co1"># Fill in these parameters</span><br /> <span class="re3">$Command</span> = <span class="st0">&quot;tsshutdn.exe 900 /reboot /delay:300 /v&quot;</span><br /> <span class="co1"># Time in HHMMSS (24h)</span><br /> <span class="re3">$Time</span> = <span class="st0">&quot;020000&quot;</span><br /> <span class="re3">$Repeat</span> = <span class="re3">$true</span></p><p><span class="co1"># if $Repeat = False then $Days must be 0 else combine days with -bor</span><br /> <span class="re3">$Days</span> = <span class="re3">$Mo</span> <span class="re2">-bor</span> <span class="re3">$We</span> <span class="re2">-bor</span> <span class="re3">$Fr</span><br /> <span class="co1"># End fill in</span></p><p><span class="co1"># Compose StartTime String</span><br /> <span class="re3">$StartTime</span> = <span class="re4"><span class="br0">&#91;</span><span class="kw3">System</span>.<span class="kw3">String</span><span class="br0">&#93;</span></span>::<span class="me2">Concat</span><span class="br0">&#40;</span><span class="st0">&quot;********&quot;</span>, <span class="re3">$Time</span>, <span class="st0">&quot;.000000&quot;</span>, <span class="re3">$Sign</span>, <span class="re3">$Bias</span><span class="br0">&#41;</span></p><p><span class="co1"># Add the task, note that DaysOfMonth and InteractWithDesktop (last 2 params) are not used</span><br /> <span class="br0">&#40;</span><span class="re4"><span class="br0">&#91;</span><span class="kw3">wmiclass</span><span class="br0">&#93;</span></span><span class="st0">&quot;Win32_ScheduledJob&quot;</span><span class="br0">&#41;</span>.<span class="me1">Create</span><span class="br0">&#40;</span><span class="re3">$Command</span>, <span class="re3">$StartTime</span>, <span class="re3">$Repeat</span>, <span class="re3">$Days</span>, <span class="re3">$null</span>, <span class="re3">$false</span><span class="br0">&#41;</span></div> ]]></content:encoded> <wfw:commentRss>http://www.remkoweijnen.nl/blog/2011/01/31/powershell-script-to-add-reboot-scheduled-task-for-citrix/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>PowerShell Script to raise Citrix Video Memory</title><link>http://www.remkoweijnen.nl/blog/2011/01/28/powershell-script-to-raise-citrix-video-memory/</link> <comments>http://www.remkoweijnen.nl/blog/2011/01/28/powershell-script-to-raise-citrix-video-memory/#comments</comments> <pubDate>Fri, 28 Jan 2011 14:23:08 +0000</pubDate> <dc:creator>Remko</dc:creator> <category><![CDATA[Citrix]]></category> <category><![CDATA[PowerShell]]></category> <category><![CDATA[script]]></category> <category><![CDATA[Windows 2003]]></category> <category><![CDATA[Windows Internals]]></category><guid isPermaLink="false">http://www.remkoweijnen.nl/blog/?p=1316</guid> <description><![CDATA[On a Citrix XenApp 5 environment a user reported that he was unable to start a Full Screen session on a Dual Monitor Configuration. He received this error message: Citrix has a KB Article: &#8220;How to Allow More Memory for Session Graphics on Windows Server 2003&#8221; that explains exactly how we can solve this. We [...]]]></description> <content:encoded><![CDATA[<p>On a Citrix XenApp 5 environment a user reported that he was unable to start a Full Screen session on a Dual Monitor Configuration.</p><p>He received this error message:</p><p><a  rel="lightbox" href="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/01/foutmelding-2.png" class="thickbox no_icon" title="foutmelding (2)"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="foutmelding (2)" src="http://www.remkoweijnen.nl/blog/wp-content/uploads/2011/01/foutmelding-2_thumb.png" border="0" alt="foutmelding (2)" width="244" height="78" /></a></p><p>Citrix has a KB Article: &#8220;<a  href="http://support.citrix.com/article/CTX114497" target="_blank">How to Allow More Memory for Session Graphics on Windows Server 2003</a>&#8221; that explains exactly how we can solve this.</p><p>We need to change the <em>MaxLVBMem</em> registry value and we can use the Excel Sheet from the KB Article to calculate the proper value.</p><p>Please don&#8217;t set this value too high because a higher value means you will restrict other kernel memory pools.</p><p>You also need to deny the SYSTEM account the SetValue permission on the <em>HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management</em> key to prevent the Citrix IMA service from overwriting the new value.</p><p>So I wrote a small PowerShell script to change the permission and set the value:</p><div class="dean_ch" style="white-space: wrap;"><span class="re3">$keyName</span> = <span class="st0">&quot;SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\icawd\thin16&quot;</span><br /> <span class="re3">$valueName</span> = <span class="st0">&quot;MaxLVBMem&quot;</span><br /> <span class="co1"># Calculate your value! http://support.citrix.com/article/CTX114497</span><br /> <span class="re4"><span class="br0">&#91;</span><span class="kw3">int</span><span class="br0">&#93;</span></span><span class="re3">$value</span> = 0xc00000</p><p><span class="co1"># Set Identity to SYSTEM via it&#8217;s Well Known SID</span><br /> <span class="re4"><span class="br0">&#91;</span><span class="kw3">System</span>.<span class="me1">Security</span>.<span class="me1">Principal</span>.<span class="me1">SecurityIdentifier</span><span class="br0">&#93;</span></span><span class="re3">$ident</span> = <span class="st0">&quot;S-1-5-18&quot;</span></p><p><span class="co1"># Open Registry Key (with Write Permissions)</span><br /> <span class="re3">$regKey</span> = <span class="re0">Get-<span class="re1">Item</span></span> <span class="st0">&quot;HKLM:&quot;</span><br /> <span class="re3">$regKey</span> = <span class="re3">$regKey</span>.<span class="me1">OpenSubKey</span><span class="br0">&#40;</span><span class="re3">$keyName</span>, <span class="re3">$true</span><span class="br0">&#41;</span></p><p><span class="co1"># Fetch Existing permissions</span><br /> <span class="re3">$acl</span> = <span class="re3">$regKey</span>.<span class="me1">GetAccessControl</span><span class="br0">&#40;</span><span class="br0">&#41;</span></p><p><span class="co1"># Construct a new Ace</span><br /> <span class="re3">$rights</span> = <span class="re4"><span class="br0">&#91;</span>Enum<span class="br0">&#93;</span></span>::<span class="me2">Parse</span><span class="br0">&#40;</span><span class="re4"><span class="br0">&#91;</span>Security.<span class="me1">AccessControl</span>.<span class="me1">RegistryRights</span><span class="br0">&#93;</span></span>, <span class="st0">&quot;SetValue&quot;</span><span class="br0">&#41;</span><br /> <span class="re3">$deny</span> = <span class="re4"><span class="br0">&#91;</span>Enum<span class="br0">&#93;</span></span>::<span class="me2">Parse</span><span class="br0">&#40;</span><span class="re4"><span class="br0">&#91;</span>Security.<span class="me1">AccessControl</span>.<span class="me1">AccessControlType</span><span class="br0">&#93;</span></span>, <span class="st0">&quot;Deny&quot;</span><span class="br0">&#41;</span><br /> <span class="re3">$rule</span> = <span class="re0">New-<span class="re1">Object</span></span> Security.<span class="me1">AccessControl</span>.<span class="me1">RegistryAccessRule</span><span class="br0">&#40;</span><span class="re3">$ident</span>, <span class="re3">$rights</span>, <span class="re3">$deny</span><span class="br0">&#41;</span></p><p><span class="co1"># Add the new Ace to the Acl</span><br /> <span class="re3">$acl</span>.<span class="me1">AddAccessRule</span><span class="br0">&#40;</span><span class="re3">$rule</span><span class="br0">&#41;</span></p><p><span class="co1"># Apply the new Acl to the Registry key:</span><br /> <span class="re3">$regKey</span>.<span class="me1">SetAccessControl</span><span class="br0">&#40;</span><span class="re3">$acl</span><span class="br0">&#41;</span></p><p><span class="co1"># Now set the required Value</span><br /> <span class="re3">$regKey</span>.<span class="me1">SetValue</span><span class="br0">&#40;</span><span class="re3">$valueName</span>, <span class="re3">$value</span><span class="br0">&#41;</span></p><p><span class="co1"># Close the key</span><br /> <span class="re3">$regKey</span>.<span class="me1">Close</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div> ]]></content:encoded> <wfw:commentRss>http://www.remkoweijnen.nl/blog/2011/01/28/powershell-script-to-raise-citrix-video-memory/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Script to install all print drivers on Citrix or Terminal Server</title><link>http://www.remkoweijnen.nl/blog/2011/01/25/script-to-install-all-print-drivers-on-citrix-or-terminal-server/</link> <comments>http://www.remkoweijnen.nl/blog/2011/01/25/script-to-install-all-print-drivers-on-citrix-or-terminal-server/#comments</comments> <pubDate>Tue, 25 Jan 2011 14:24:14 +0000</pubDate> <dc:creator>Remko</dc:creator> <category><![CDATA[Altiris]]></category> <category><![CDATA[Citrix]]></category> <category><![CDATA[PowerShell]]></category> <category><![CDATA[Terminal Server]]></category><guid isPermaLink="false">http://www.remkoweijnen.nl/blog/?p=1292</guid> <description><![CDATA[I wrote a PowerShell script to install all printer drivers on a Citrix or Terminal Server. Actually the script isn&#8217;t specific to Citrix or Terminal Server but on such environments we need to preload all drivers because users do not have the permissions to do that. I have chosen for PowerShell because you can do [...]]]></description> <content:encoded><![CDATA[<p>I wrote a PowerShell script to install all printer drivers on a Citrix or Terminal Server.</p><p>Actually the script isn&#8217;t specific to Citrix or Terminal Server but on such environments we need to preload all drivers because users do not have the permissions to do that.</p><p>I have chosen for PowerShell because you can do it in a one-liner which makes it easy to run this script from my Altiris server on all Citrix Servers.</p><p>The idea is that we enumerate all the shared printers on a Printer Server and make a connection to each printer. This will make sure that the driver is installed if it wasn&#8217;t already present.</p><p>The script could even be scheduled to enforce that newly added printer drivers are added to each Citrix Server.</p><p><span id="more-1292"></span></p><p>To enumerate all printers we can use the <a  href="http://msdn.microsoft.com/en-us/library/aa394363(v=vs.85).aspx" target="_blank">Win32_Printer</a> WMI class like this:</p><div class="dean_ch" style="white-space: wrap;"><span class="re0">Get-<span class="re1">WmiObject</span></span> win32_printer <span class="re2">-ComputerName</span> <span class="st0">&quot;MYSERVER&quot;</span></div><p>It&#8217;s possible that some printers are not shared so we are going to filter that out using the -filter parameter:</p><div class="dean_ch" style="white-space: wrap;"><span class="re0">Get-<span class="re1">WmiObject</span></span> win32_printer <span class="re2">-ComputerName</span> <span class="st0">&quot;MYSERVER&quot;</span></div><p>Our next step is to make a printer connection and MSDN shows that the win32_printer class has an <a  href="http://msdn.microsoft.com/en-us/library/aa384769(v=vs.85).aspx" target="_blank">AddPrinterConnection</a> method.</p><p>So I first tried:</p><div class="dean_ch" style="white-space: wrap;"><span class="re3">$Wmi</span>.<span class="me1">AddPrinterConnection</span><span class="br0">&#40;</span><span class="st0">&quot;\\MYSERVER\PRINTER&quot;</span><span class="br0">&#41;</span><br /> Method invocation failed because <span class="re4"><span class="br0">&#91;</span><span class="kw3">System</span>.<span class="me1">Object</span><span class="br0">&#91;</span><span class="br0">&#93;</span><span class="br0">&#93;</span></span> doesn<span class="st0">&#8216;t contain a method named &#8216;</span>AddPrinterConnection<span class="st0">&#8216;.<br /> At line:1 char:26<br /> + $Wmi.AddPrinterConnection &lt;&lt;&lt;&lt; (&quot;\\SERVER\PRINTER&quot;)<br /> &nbsp; &nbsp; + CategoryInfo &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: InvalidOperation: (AddPrinterConnection:String) [], RuntimeException<br /> &nbsp; &nbsp; + FullyQualifiedErrorId : MethodNotFound</span></div><p>I am not sure of the exact reason but obviously there is no access to the AddPrinterConnection method.</p><p>This works though:</p><div class="dean_ch" style="white-space: wrap;"><span class="re3">$Wmi</span> = <span class="br0">&#40;</span><span class="re4"><span class="br0">&#91;</span><span class="kw3">wmiclass</span><span class="br0">&#93;</span></span><span class="st0">&quot;Win32_Printer&quot;</span><span class="br0">&#41;</span><br /> <span class="re3">$Wmi</span>.<span class="me1">AddPrinterConnection</span><span class="br0">&#40;</span><span class="st0">&quot;\\MYSERVER\PRINTER&quot;</span><span class="br0">&#41;</span></div><p>Now we can use the For-Each Object to make a connection to each printer using the __SERVER property for the servername and the ShareName property for the Printername:</p><p>Once again I met a PowerShell oddity: I couldn&#8217;t use AddPrinterConnection(&#8220;\\$_.__SERVER\$_.ShareName&#8221;) so I used:</p><div class="dean_ch" style="white-space: wrap;"><span class="re3">$Wmi</span>.<span class="me1">AddPrinterConnection</span><span class="br0">&#40;</span> <span class="re4"><span class="br0">&#91;</span><span class="kw3">string</span><span class="br0">&#93;</span></span>::<span class="me2">Concat</span><span class="br0">&#40;</span><span class="st0">&quot;\\&quot;</span>, <span class="re3">$_</span>.__SERVER, <span class="st0">&quot;\&quot;</span>, <span class="re3">$_</span>.<span class="me1">ShareName</span><span class="br0">&#41;</span> <span class="br0">&#41;</span></div><p>And finally we put the whole thing in a one liner, replacing double quote (&#8220;) with (&#8216;) and using the gwmi alias to make the line shorter:</p><div class="dean_ch" style="white-space: wrap;"><span class="kw3">powershell</span>.<span class="me1">exe</span> <span class="st0">&quot;&amp; { $Wmi = ([wmiclass]&#8216;Win32_Printer&#8217;) ; $Wmi.Scope.Options.EnablePrivileges = $true; gwmi win32_printer -ComputerName &#8216;ADNRD02&#8242; -Filter &#8216;shared=true&#8217; | foreach {$Wmi.AddPrinterConnection( [string]::Concat(&#8216;\\&#8217;, $_.__SERVER, &#8216;\&#8217;, $_.ShareName) )} }&quot;</span></div><p><span style="color: #ff0000;"><strong>EDIT:</strong></span> In order to load new driver we need to enable the SeLoadDriverPrivilege. I have corrected the code above,  see <a  href="http://www.remkoweijnen.nl/blog/2011/01/27/enabling-privileges-for-wmi-in-powershell/">Enabling Privileges for WMI in PowerShell</a> for an explanation.</p> ]]></content:encoded> <wfw:commentRss>http://www.remkoweijnen.nl/blog/2011/01/25/script-to-install-all-print-drivers-on-citrix-or-terminal-server/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> </channel> </rss>
