'Startup VB script to move clients from Citrix Presentation Server 4.5 to XenApp 6.5
on error resume next
Dim WshShell, Fso, strUninstall, strExecutable, strArguments, count
Set WshShell = CreateObject("WScript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")

' Uninstall Citrix Program Neighborhood Client 
strUninstall = WshShell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Citrix Program Neighborhood\UninstallString") 
If Not (strUninstall = "") Then 

   ' Divide UninstallString into Executable and Arguments strings
   For i = 0 to Len(strUninstall)
      strExecutable = Left(strUninstall, i)
      strExecutable = Replace(strExecutable, """", "")
      If Fso.FileExists(strExecutable) Then
         strExecutable = Trim(strExecutable)
         count = i
         Exit For
      End If
   Next

   If Not (strExecutable = "") Then
      strArguments = Right(strUninstall, Len(strUninstall) - count)
      WshShell.Run """" & strExecutable & """ " & strArguments & " -a", 1, True 
   End If

End If

' Install Citrix Online Plugin Full 12.3
strUninstall = WshShell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\CitrixOnlinePluginFull\UninstallString") 
If (strUninstall = "") Then 
   WshShell.Run "\\share\CitrixOnlinePluginFull.exe /silent /forcerestart", 1, True
End If

' Specify ServerURL address of  XenApp Farm 
WshShell.RegRead("HKLM\SOFTWARE\Citrix\PNAgent\ServerURL")
If Err = 0 Then 
      WshShell.RegWrite "HKLM\SOFTWARE\Citrix\PNAgent\ServerURL", "YourServerURL", "REG_SZ"
End If

' Install ThinPrint Client 8.6 for ICA connection 
If Not (Fso.FileExists((WshShell.ExpandEnvironmentStrings("%PROGRAMFILES%"))&"\Common Files\ThinPrint\TPClnt.dll")) Then
   WshShell.Run "msiexec /qn /i " & """\\share\ThinPrint Client Windows 8.6.msi""" & " ADDLOCAL=ICA" , 1, True
End If