Citrix Clipboard issues in a published desktop environment

November 24, 2009 Andrew Morgan 4 comments

It amazes me in this day and age that something as fundamentally simple as the clipboard in a windows environment can have issues, but it does happen… Especially in a multi user environment.

If you experience clipboard issues with office, Lotus notes and other copy and paste capable programs you have have a session memory issue!

The session View size and pool size have a massive part to play in 32 bit citrix environments, these size options dictate the amount of graphical memory that can be assigned to each session. The ceiling for these options in 32 bit are just 16mb, which rediculously low in modern days.

Taking equal parts of graphically heavy applications like Office 2007 and Known citrix killers like lotus notes, it really isn’t long until these limits spill over into horrible clipboard and copy / paste disasters. Take one step further and implement Microsoft App-V and you are in serious trouble.

If alike me, you run an environment that requires all the above nasties, help is at hand. After 12 months of continued troubleshooting I’ve found a happy medium of 64mb between low limits and too high limits.

To test the same, simply bash these off the following command lines and reboot, waving goodbye to your horrible clipboard issues:

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management” /v SessionPoolSize /t reg_dword /d 64 /f
reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management” /v SessionViewSize /t reg_dword /d 64 /f

Disclaimer:

We currently run with 10gb of memory, allowing us to allocate this extra 112mb of memory per user. If you require these options, consider a lower value or upgrade your ram capacity

Categories: Citrix Tags: , ,

Enabling disk caches from a script

November 24, 2009 Andrew Morgan Leave a comment

Just a quick post to share a fundamental performance increase to any citrix server out there running on local disk. If your disk supports caching, enable it now!

Get a copy of dskcache.exe from here:

run the following command: dskcache.exe +w +p

Enjoy your new disk performance!

Categories: Administration Tags: ,

Intermittent Thin Client disconnects

October 24, 2009 Andrew Morgan Leave a comment

We recently had a problem after a Citrix rebuild where we were seeing thin clients intermittently disconnect from the citrix servers. Nothing in the event logs, just a lovely error on the Thin Client (Igel) reporting a Driver protocol error. The users could immediately reconnect, but 10-15 disconnects a day was getting a bit annoying for poor Joe Soap.

The problem was very difficult to track down due to absolutely no logging or even acknowledgement of the problem in any event logs.

We found that the reinstall was enabling the advanced IP features in Windows server 2003 involving TCP Offloading from the Nic to the CPU, Citrix and particularly thin clients do not like this feature one bit.

To disable these options, enter the following keys into the registry and reboot.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
“EnableTCPA”=dword:00000000
“EnableRSS”=dword:00000000
“EnableTCPChimney”=dword:00000000

On a side note, I’ll be disabling these keys going forward on all server builds, its not a nice feature to implement unless the application is aware of the offload.

Categories: Citrix Tags: ,

Internet explorer 7 wont launch

September 7, 2009 Andrew Morgan Leave a comment

Internet-Explorer-8Had a weird one over the weekend. A colleague of mine accidentally approved Internet Explorer 8 to all servers in our domain via wsus and it left our Citrix servers in a bit of a sad state. We set about removing it as soon as possible but after the uninstall / restart we were faced with this very strange problem. When we double clicked internet explorer on the desktop, the application wouldnt launch and a new shortcut to Internet Explorer would be created on the desktop.

We also had these logged every thirty minutes or so in the event logs:

Event Type:    Error
Event Source:    Userenv
Event Category:    None
Event ID:    1041
Date:        06/09/2009
Time:        21:50:38
User:        NT AUTHORITY\SYSTEM
Computer:    LPGPCTXXA0008
Description:
Windows cannot query DllName registry entry for {7B849a69-220F-451E-B3FE-2CB811AF94AE} and it will not be loaded. This is most likely caused by a faulty registration.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

And:

Event Type:    Error
Event Source:    Userenv
Event Category:    None
Event ID:    1041
Date:        06/09/2009
Time:        21:50:38
User:        NT AUTHORITY\SYSTEM
Computer:    LPGPCTXXA0008
Description:
Windows cannot query DllName registry entry for {CF7639F3-ABA2-41DB-97F2-81E2C5DBFC5D} and it will not be loaded. This is most likely caused by a faulty registration.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

If you face the above problems, delete the following registry keys and open internet explorer as an administrator:

“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions\{CF7639F3-ABA2-41DB-97F2-81E2C5DBFC5D}” /f
“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions\{7B849a69-220F-451E-B3FE-2CB811AF94AE}” /f
“HKEY_CLASSES_ROOT\CLSID\{871C5380-42A0-1069-A2EA-08002B30309D}\shell\OpenHomePage” /v legacydisable /f

That should fix that!

Categories: Administration

Enabling RDP on a server remotely.

September 4, 2009 Andrew Morgan Leave a comment

There’s very litte more annoying in a windows environment than having to go to a console of a server because some idiot has disabled remote administration on a server 2003/2000 server. I was in this situation recently and decided not to go to the console out of principle.

rdpon

I wrote the following program in order to get around this issue. Its called RDPon.exe and you can get it here:

With this you can:

  • Query RDP status
  • Enable RDP
  • Disable RDP

I have sealed it as an exe so that you can right click it and choose run as to get at your admin account easily.

Categories: Personal, Tools Tags: ,

Determining if a number is odd or even using a batch file

September 4, 2009 Andrew Morgan Leave a comment

Our challenge recently was seperating the reboots of our citrix servers to ensure that half of our farm is always available. This is particularly useful if you are a 24/7 house and need to know exactly what servers restart and when they restart.

So to begin, our server names consist of “servername00xx” where xx is the number of the server, the task at hand was to ensure that 0001, 0003, 0005 etc restarted on one night and 0002, 0004, 0006 etc restarted the second night. To do this i needed to use the system variable “hostname” and read the last digit in the name to determine if the number was odd or even.

To get determine whether a number is odd or even i used the following logic. If you divide an even number by 2 then multiply it by two you will get the same number back, e.g. 8/2 = 4, 4*2 = 8, 8 is equal to 8 .

An odd number in batch is treated as follows 9/2=4, 4*2=8 ,9 is NOT equal to 8.

Rem Begining Logic Check for even or odd server
for /f “tokens=1-2 delims=00″ %%a in (‘hostname’) do set compnumber=%%b
set /a divnumber=%compnumber%/2
set /a sum=%divnumber%*2

With the above excerpt, i set three variables, %compnumber% (which is the number after the 00), divnumber (a variable for the result of the computernumber divided by two) and sum, which is the resulting divnumber * 2.

This divides compnumber by 2 and multiplys divnumber by 2 setting the resulting number to sum.

Rem Running if checks
if %compnumber% NEQ %sum% goto odds
if %compnumber% EQU %sum% goto evens

This next step is our determiner:

If the number divided by two and multiplied by two is not the same as the original number, the number is odd, the if statement then sends the script to the odds labeled portion of our script.

If the number divided by two and multiplied by two is the same as the original number, well you get the idea, its even and jumps down.

:o dds
<—Do something for odd servers here—>
exit

:evens
<—Do something for even servers here—>
exit

Categories: Citrix, Scripting

Forcing a printer online using a script:

printer_iconRecently while installing Zetafax 11, we noticed that some of our maintenance scripts on our XenApp servers were causing the zetafax printer to fall offline on reboot. Below is a simple to use (built in to server 2003) script that can be used to force a printer online.

The Following will force “Printer Name” to work online:

cscript C:\WINDOWS\system32\prncnfg.vbs -t -p “Printer Name” -workoffline

As an extra function, the below will rename a local printer:

Cscript %windir%\system32\Prncnfg.vbs -x -p “old printer name” -z newprintername

Categories: Scripting Tags: ,

Restarting a server at a certain time from accross the LAN.

March 8, 2009 Andrew Morgan 2 comments

Just a quick entry as i got an email requesting this today, “How can i schedule a restart on a remote server to run out of hours?”

This script uses at.exe which is soon replaced by schtasks.exe. This can only be run by an administrator of the server you wish to restart, obviously.

Rem setting vars:
set server=servertorestart
set time=05:00

REM performing check for previous file and deleting it:
if exist
\\%server%\c$\rebootme.bat del \\%server%\c$\rebootme.bat

Rem Creating reboot batch file:
echo shutdown -r -t 03 >>
\\%server%\c$\rebootme.bat

Rem Schedueling the job:
at
\\%server% %time% c:\rebootme.bat

To Create a reuseable, error checking script with idiot proof options! save  the following as a .bat file:

@echo off
cls
Rem setting vars:
set /p server=[Please enter the name of the server you wish to restart:]
cls
echo Selected server = %server%
set /p time=[Please enter the time  in HH:MM format at which you wish to restart the server: e.g. 05:00]
cls

REM performing final idiot check
echo Are you absolutely sure you wish to restart %server% at %time%?
Pause

REM performing check for previous file and deleting it:
if exist
\\%server%\c$\rebootme.bat del \\%server%\c$\rebootme.bat & echo deleted previous file

Rem Creating reboot batch file:
echo shutdown -r -t 03 >>
\\%server%\c$\rebootme.bat

Rem Ensuring reboot file exists:
if exist
\\%server%\c$\rebootme.bat echo reboot script created successfully.
if not exist
\\%server%\c$\rebootme.bat goto Failed

Rem Schedueling the job:
at
\\%server% %time% c:\rebootme.bat
Echo Job schedueled, Script complete.
pause

:failed
echo something failed, I’d look into that if i were you.

pause
exit

Categories: Antivirus, Citrix

Disabling Dep with a script

March 8, 2009 Andrew Morgan 1 comment

We had this problem recently with our XenApp servers, as part of the latest service pack DEP (or Data Execution Protection) has now been enabled for all applications accross all platforms and this can cause havok in a terminal services environment.

The problem with Dep is simple, its not a Reg Key, its not an environment variable its a system setting loaded on startup from the boot.ini file. To make matters worse its a kinda complicated setting as it sounds opposite to what it is exactly doing.

Take this for example, this is a server with DEP enabled:

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS=”Windows Server 2003, Standard” /NoExecute=OptOut /fastdetect

What confuses me with the above statement is why Opting out means DEP is enabled? To disable DEP you need to change this switch to OptIn, which makes no sense to me at all.

To automate this change, i used a tool called RPL.exe, this is a direct translation of the Unix command/tool to replace text inside of a text file. Using RPL i could search the boot.ini for the optout statement and replace it with the optin (aka turn off Dep).

Because boot.ini is a system and read only file by default, i needed to use the attrib command so first i set about removing the read only, hidden and system file attributes on the file in order to edit it:

attrib -r -h -s c:\boot.ini

once the file was editable, i now performed the rpl command to search and replace:

rpl.exe -i /noexecute=optout /NoExecute=OptIn c:\boot.ini

Once the file had been changed if neccessary it was time to set the file back to read only, hidden and system before closing the script:

attrib +r +h +s c:\boot.ini

And voila, next reboot and Dep is gone :)

How to hide a local printer on a Terminal / XenApp Server

We had a problem recently with the adobe professional suite installing a local printer on the XenApp server, this was great for users licensed to use Adobe Professional, but for users that weren’t it gave them a possibility to infringe the licensing simply by printing to this printer.

To limit the printer, you simply need to assign custom permissions to the printer. Allowing members of a group the ability to print to it (i.e. adobe professional users) and restricting everyone else. This works brilliantly as if the user has no permissions to the printer the user cant even see it!

This can be done manually if you wish, but you can also script it using SetAcl.exe.

The documentation on their website is shockingly bad for printers, so below is an example of how to remove the permissions from a local printer:

setacl.exe -on “adobe pdf” -ot prn -actn clear -clr dacl,sacl

The following will grant the “local administrators” group full control of the printer for troubleshooting:

setacl.exe -on “adobe pdf” -ot prn -actn ace -ace “n:administrators;p:full”‘

And the following will grant the domain group “apps acrobat writer” the ability to view and print to the printer

setacl.exe -on “adobe pdf” -ot prn -actn ace -ace “n:domain\Apps Acrobat Writer 9;p:print”

 The whole lot together is below in Enteo scripting format:

Execute(‘.\extern$\setacl.exe -on “adobe pdf” -ot prn -actn clear -clr dacl,sacl’)/?
Execute(‘.\extern$\setacl.exe -on “adobe pdf” -ot prn -actn ace -ace “n:administrators;p:full”‘)/?
Execute(‘.\extern$\setacl.exe -on “adobe pdf” -ot prn -actn ace -ace “n:emea\LPGP CTX Apps Acrobat Writer 9;p:print”‘)/?

Categories: Citrix

Increasing the App-V cache size with a script:

February 12, 2009 Andrew Morgan Leave a comment

For anyone out there that wishes to increase the App-V cache beyond 10gb, this will be handy info.

Well for starters, the size of the cache is dictated by a reg key in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SoftGrid\4.5\Client\AppFS called FileSize, useless information unfortunately as changing this key makes no difference after a restart. So i did a bit of googling and found a tool called cachesizetool which boasted to do exactly what I wanted, after a quick glance at the readme I tested the command and I get stuck with a big dirty EULA prompting me to accept it… I saw this before with Pstools after they were purchased by microsoft but at least they had the decency to include a /accepteula switch, but with this tool there is no such option.

So it raises the question really, why bother your arse writing a command line tool then force the user to accept an eula? It’s mind blowing how stupid this is really. It’s like putting petrol in the car then getting the bus…

anyway to cut a long story short, accepting the eula creates a reg key, and this key can be forced in before running the command to ensure you dont get prompted…

reg add hkcu\software\microsoft\appvtools\cachesizetool /v Eulaaccepted /d 1 /t reg_dword /f’
AppVCacheSize.exe /s:20480

Categories: App-V, Citrix

App-V applications hang for 30 seconds on a CMD box before opening

January 24, 2009 Andrew Morgan Leave a comment

In our powerfuse environment we came accross this problem recently.

When we would try to launch an App-V application the following window would open and remain open for 30 + seconds before finally opening the application:

appv-application

The problem we discovered was to do with file type associations inside of the RES session, App-V by default will try to associate it’s file type associations for the application being sequenced and store them in the .osd file. The problem was that PowerFuse also controls file associations and this became an issue! PowerFuse has to be associated with the app and not vice versa.

I recommend you specify the file type associations inside of powerfuse and remove the associations inside of the App-V package. To remove the associations, open the .osd file and remove anything between the <FILEEXTENSIONLIST>  </FILEEXTENSION>:

After the link is an example.

Read more…

Categories: App-V, PowerFuse Tags: ,

Java IE add in missing when installed from MSI.

January 17, 2009 Andrew Morgan Leave a comment

java-image

I ran into this problem recently on our Citrix environment and it really perplexed me. We install Java via Enteo, We use the msi version of the java installation and we noticed that the java console was missing from internet explorer! At first i thought it was due to installing ie7 later in the script but it turns out the MSI does not install the IE addon by default!

If you are wondering how to get an msi for java (Suns website only provides an .exe) look here: Link

The command neccessary to install java and include the IE addon is below:

java.msi  IEXPLORER=1

The full command we use is:

msiexec /i java.msi /LV C:\JAVA.LOG /QB REBOOT=supress IEXPLORER=1

This will install Java write a log to c:\java.log and repress a reboot if neccessary.

Below are the rest of the undocumented switches, might save you some time :)


IEXPLORER=1 indicates that the JRE should be registered with the Internet Explorer browser
NETSCAPE6=1 indicates that the JRE should be registered with Netscape 6 or later browsers
MOZILLA=1 indicates that the JRE should be registered with Mozilla 1.1 and later browsers
INSTALLDIR specifies the drive and path of the installation
REBOOT=Suppress indicates that if locked files are encountered the computer should not be rebooted
JAVAUPDATE=1 indicates that Java Update feature is enabled

Categories: Scripting Tags: ,

Remove “Combine supported files in acrobat” after installing acrobat 8

January 12, 2009 Andrew Morgan 2 comments

A pet peeve of mine are context menu extensions… Why software vendors decide to include completely useless context menu addons are besides me! A good example of this would be Adobe.

when right clicking  on an office document Adobe decided  “Combine supported files in acrobat” to be a useful function !?!

To remove this tat from your Citrix environment / Desktop simply run this command:

REGSVR32 /u “C:\Program Files\Adobe\Acrobat 9.0\Acrobat Elements\ContextMenu.dll.

If you also wish to remove the New > file type associations that Adobe decide to push in, heres a script to do so:

REG DELETE HKEY_CLASSES_ROOT\.xdp\AcroExch.XDPDoc\ShellNew /f
REG DELETE HKEY_CLASSES_ROOT\.xdp\ShellNew /f

Categories: Citrix, Scripting Tags: , ,

Scripting Web interface 5.0 installation.

January 6, 2009 Andrew Morgan Leave a comment

To auto install web interface sites, sitemgr.exe must be ctxapp12used. the below script will create a default website for XenApp services and will also create a PNAgent site.

The pre Requisits for this script are:

·         Installation of IIS 6.0 +

·         Installation of .net framework 3.5

·         Installation of J#

·         Installation of Citrix access management console framework (and web interface component).

·         Installation of citrix web interface.

 

Configure your variables for the management servers and farm names, then save the below as a batch file:

set sitemgrdir=C:\Program Files\Citrix\Web Interface\5.0.1
set mgmtservers=server0001;server0002
set farmname=farm01

“%sitemgrdir%”\sitemgr.exe -c “WIDest=1:/Citrix/XenApp,Config=local,XMLService=%mgmtservers%,farmname=%farmname%,XMLSPort=80,WIDefaultSite=yes”‘)/?
“%sitemgrdir%”\sitemgr.exe -c “PNADest=1:/Citrix/PNAgent,Config=local,XMLService=%mgmtservers%,farmname=%farmname%,XMLSPort=80″‘)/?

The script in full can be downloaded here

Categories: Citrix, Scripting Tags: ,

How do you force citrix clients to behave?

January 2, 2009 Andrew Morgan Leave a comment

ctxapp13Wondering why alt and tab is hit and miss in your citrix session? Can’t seem to figure out why it windows key and D isn’t passing through? You aren’t the first to have this problem and certainly wont be the last.

Despite what you set in the client options, on the application settings or even the web interface / PNAgent options, sometimes these settings just will not work.

If frustration is getting the best of you, setting the below in the default.ica file on the web interface or PNAgent will force the ICA client to behave itself, despite application or client settings.

The default.ica file can be found in %systemdrive%\Inetpub\wwwroot\Citrix\%sitename%\conf where sitename is the name of the site (typically XenApp/PNAgent etc).

The following entries can be added to the bottom of their prospective heading, I’ve retained the heading for each entry for ease of use:

Force keyboard mapping to the citrix session:

[WFClient]
TransparentKeyPassthrough=Remote

Force the Ica client to ignore citrix seamless settings:

[Application]
TWIMode=Off
ScreenPercent=100

A full list of ica file options can be found here.

Categories: Citrix Tags:

How do you move a computer automatically from one OU to another using a script?

December 16, 2008 Andrew Morgan 1 comment

I was asked the following question recently when finishing our Citrix server deployment method.

We needed a script that would run on a computer as part of a sequence of scripts that would move a server from its current OU to the servers final resting place a terminal servers OU.

The below script achieved what we needed by using the computers %computername% variable to move the computer.

In our case the following apply:

· The computers name is using the variable %computername%

· The domain is domain.net

· The computers OU before the move is computers

· The OU we wish to move to is Terminal Servers

dsmove “CN=%computername%,OU=computers,DC=domain,DC=net” -d domain.net -newparent OU=”Terminal Servers”,DC=domain,DC=net

if you are unaware of the computers current OU before the move and you still wish to script the move, the following forum post will get you in the right direction.

Categories: Enteo, Scripting Tags: ,

Applications appear over the taskbar on IGel Thin Clients

November 22, 2008 Andrew Morgan Leave a comment

ctxapp14This problem perplexed us recently, when launching a published desktop from a thin client (Igel in our case) microsoft office and other applications when in full screen would hide the taskbar.

This behavior was not seen on fat clients using the 10 and 11 windows ica client.

The Fix was found in the following reg key,

HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\CtxHook\AppInit_Dlls\Multiple Monitor Hook

configuring this reg dword value to 0 and restarting the citrix servers fixed the problem.

Categories: Citrix Tags:

Igel Database command mistake.

November 16, 2008 Andrew Morgan Leave a comment

Despite Igels better judgement, the command they have published in their documentation to create an SQL database does not work. The command itself can be found here.

The actual working command is listed below, thanks to J Booker in Igel for the help.

CREATE DATABASE rmlogin
GO
USE rmlogin
GO
CREATE LOGIN rmlogin with PASSWORD = ‘Passw0rd’
GO
CREATE USER rmlogin with DEFAULT_SCHEMA = rmlogin
GO
CREATE SCHEMA rmlogin AUTHORIZATION rmlogin
GRANT CONTROL to rmlogin
GO

Categories: Scripting Tags: , ,

Enteo: The 10 minute rule on batch files.

November 10, 2008 Andrew Morgan 4 comments

Heres a tricky problem with Enteo, When executing a batch file enteo only gives a batch file 10 minutes to complete before moving on.

Generally speaking this is no problem as how many batch files do you run take over 10 minutes?

This problem came to light for us when enteo began causing our ESX servers to purple screen of death during the pe stage of the build, which resulted in us moving our virtual servers to a stable ESX while we rebuilt. The problem was that the ESX was so slow with all the added servers that our scripted citrix updates were taking over 10 minutes, the script continued, rebooted the server during the updates and low and behold a very sick citrix server.

The trick to get around this, and i recommend this for any batch file you run in enteo, is to create a looping if statement in the enteo script to check for a registry key. Once you have this key created run your updates then delete the key as the last line in your batch file. This will cause enteo to loop even after the 10 minutes leaving your critical updates to install without fear of being.

heres the idea for the enteo script:

execute %systemdrive%\longbatchfile.bat /?
:check
if exist regkey goto sleep
del %systemdrive%\longbatchfile
Exitproc
:sleep
sleep 60
goto check

And in the batchfile create the reg key, do your work then delete it:

reg add hklm\software\enteo /v checkkey
update1
update2
update3
update4
update5
reg delete hklm\software\enteo /v checkkey

what will happen is simple, even if the script times out, the script will carry on sleeping until the key is deleted, no matter how long it takes.

After the jump is an example of my code so you can see what we did to get around this :)

Read more…

Categories: Enteo, Scripting Tags: ,