Wilco van Bragt - LinkeIn Wilco van Bragt - Twitter rssa 

How to Remove old PN Settings

When upgrading to a new version of Citrix Presentation Server most times a new farm is build next to the current one. Beside there are still many companies that are using the full Citrix ICA Program Neighborhood client to present the Published Applications to their end-users. In such a situation you have to arrange "something " to remove the current Published Applications, when the new farm is ready for production.

First of all using the full PN client for presenting the Published Applications to the end-users is a bit outdated. At the moment using the Web Interface and the Citrix PN Agent are much more efficient methods to present the applications to the end user. Because the configuration is stored centrally on the Web Interface server instead of the full PN client where those settings are stored locally in the profile of the user, these methods are much easier to maintain. Therefore if you are migrating to a new Citrix Presentation Server farm I really recommend using these components to present the applications to your users.




Nevertheless it is logical that you are going to use these components for the new Farm you want to prevent the users getting confused with the existing old shortcuts to the old farm.  Even if you decide to still use the traditional Program Neighborhood you would like to remove the shortcuts to the old Published Applications.

Probably a few people are now already thinking this is not that difficult, because all these settings are stored in a configuration file (.INI) on the local workstations. In the basics this is definite true, but you should exactly now how this mechanism works and which possibilities the users have within the PN client.

First let's start with the configuration files. The settings to connect to a farm can be stored in two files:

  • PN.INI
  • APPSRV.INI

In the PN.INI the Application Sets are stored, which are defined. An application set is a connection to the farm, which will present all Published Applications where the user has rights to. This is the most common way to configure the client with a connection to the Citrix Farm. Every user has his own PN.INI located at the following location C:\Documents and Settings\%username%\Application Data\ICAClient. By removing the PN.INI out of the profile of the user the presentation of the Published Applications in the PN client are removed. But..... do not forget how this PN.INI file is build up the first time. When no PN.INI is found in the userprofile then the default PN.INI out of the Citrix PN directory (be default C:\Program Files\Citrix\ICA Client).  It is possible that this PN.INI is fully configured with settings to the old Farm, so users did not have to configure the connection the first time. If this is the case do not forget to replace the PN.INI on that location with a default empty one (or if you still want to use the PN client with a new PN with the configuration to the new Farm).

Also the APPSRV.INI can contain configuration items to Published Applications if they are created as Custom ICA connections. Probably this is not done often in infrastructures because you need to create the configuration of every Published Applications. But if this is the case you should replace the APPSRV.INI in the userprofile (same location as the PN.INI) with a default one without custom ICA connections. Also this configuration can be stored in the default APPSRV.INI located in the Citrix ICA client directory. If this is the case you should also replace this one.

Remember that by default a default user does not have right to make changes to the files located in the Citrix ICA client directory, so the replacement of these files should be done via an deployment system, a Start-up Script or a scheduled at system startup task (with the correct credentials).

The other settings are user settings in the userprofile so such settings can be changed when the user is logging on via a logon script or something similar. But I will come back to this later in this article.

Besides these configuration files there is one another possible place where shortcuts to the Published Applications can be located at that's on the Desktop of the user.

Image

When the user right clicks the Published Application with the mouse in the PN client an option is available to create a shortcut to the desktop.  Logical the user will use these shortcuts most often to start the applications so also these ones should be removed. Those shortcuts are available as normal shortcuts with an .LNK file. In the shortcut the PN.exe is used, so via this executable you can identify which shortcuts are connecting to Published Applications. Via a CMD scripting with several FOR loops it is possible to identify these shortcuts and only remove these shortcuts from the desktop of the end user (you do not want to remove the shortcuts to other programs or documents). Remember that users can move those shortcuts to other locations such as the Quick Launch. I think you should make a consideration how far you would like to go by automated removal of these shortcuts, because in theory the shortcuts can be moved to many locations.

The script I have used at one of my customers is enclosed at this article and may be used freely (although I would appreciate it if you leave some a comment that your script is based on my scripts). If you have some additions feel free to mention those in the comments component of the website, so other people you use those as well. At this customer we decided to use the PN agent to display the Published Applications to the end users. Therefore we updated the ICA client to the latest version. In this software package we added a default empty PN.INI at the ICA client location. The customer did not use any custom ICA connections so there was no need to perform any actions on the APPSRV.INI. Secondly we added the enclosed script to the logon script. If we made the user the member of a special global group the script will be executed (this was done because we were not migrating all users on the same day). At the end we created a simple text file in the userprofile if the script has been run on for that specific user on that specific workstation. We named the text file with  variables %username%%workstations%. If such a file was found that matches the current values of the variables the script was passed the next time. In the script we decided to store the files for a rollback scenario by copying the PN.INI and the shortcut files to a directory within the user home directory (in this case mapped as the U: drive).

@ECHO OFF

GOTO START

*********************************************************************************************
**
** Program     : Remove_old_PNSettings.cmd
**
** Description : Removing old Citrix connections and shortcuts on desktop
**
**
** Date                Version       Created by                                      Change
** --------------------------------------------------------------------------------------------
**  January 2007    1.0           Wilco van Bragt                               Initial version
**                                         VanBragt.Net Consultancy
**********************************************************************************************

:START

SETLOCAL

:: -------------------------------------------------------------------------
::              Read all the LNK Files on the desktop 
:: -------------------------------------------------------------------------

DIR "%USERPROFILE%\Desktop\*.lnk" /B >>%TEMP%\LNK.TXT

:: -------------------------------------------------------------------------
::              Read all the LNK files out of the text file.
:: -------------------------------------------------------------------------

FOR /F "delims= tokens=1" %%i in (%TEMP%\LNK.TXT) do call :CHECKLNK "%%i"

:: -------------------------------------------------------------------------
::              Move the current PN.INI
:: -------------------------------------------------------------------------

COPY "%USERPROFILE%\Application Data\ICAClient\pn.ini" "U:\ROAMING\XPShortcut\" /y

DEL "%USERPROFILE%\Application Data\ICAClient\pn.ini"

GOTO:END

:: -------------------------------------------------------------------------
::              CHECKLNK
:: -------------------------------------------------------------------------

:CHECKLNK

SET LINK=%~1

SET PNLINKFILE=NOVALUE

FOR /f "tokens=*" %%i IN ('FIND /i "PN.EXE" "%USERPROFILE%\Desktop\%LINK%"') DO CALL :LOGCHECK %%i

IF /i %RESULT%==FOUND SET PNLINKFILE=YES

IF %PNLINKFILE%==YES GOTO :CONTINUE

GOTO :EOF

:: -------------------------------------------------------------------------
::              If PN.EXE defined move the shortcut to U:\Roaming\XPShorcut
:: -------------------------------------------------------------------------

:CONTINUE

IF NOT EXIST U:\Roaming\XPShortcut MD U:\ROAMING\XPShortcut

COPY "%USERPROFILE%\Desktop\%LINK%" "U:\ROAMING\XPShortcut\" /y

DEL "%USERPROFILE%\Desktop\%LINk%"

GOTO :EOF

:: -------------------------------------------------------------------------
::              LOGCHECK
:: -------------------------------------------------------------------------

:LOGCHECK

                SET VALUE=%*

                IF NOT "%VALUE:~,5%"=="-----" SET RESULT=FOUND

                IF /I "%VALUE:~,5%"=="-----" SET RESULT=NOT_FOUND&GOTO :EOF

GOTO :EOF

:END

DEL %TEMP%\LNK.TXT

 

 Conclusion

When migrating to a new farm in environments where the PN client is still used it is recommend removing settings and shortcuts to the old farm to prevent confusion by the end users which shortcuts should be used to start the Published Applications. Also I provided you with a script that I used at one of my customers to remove those settings and shortcuts without any manual user interaction.