Citrix – Customize Wallpaper in Citrix Published Desktops or RDS via PowerShell

Summary

Do you publish desktops using Citrix XenDesktop or Microsoft Remote Desktop Services (RDS) and restrict users from changing display settings via Group Policy? But your users still want the ability to change their desktop background or wallpaper?

Here’s a PowerShell-based method that restores flexibility by allowing users to upload their own background image or choose from three predefined default wallpapers.

Description

The PowerShell script, along with the required images, is stored in a subfolder within the Program Files directory. It can be launched via a Start Menu or desktop shortcut.

When executed, the script generates a user-friendly graphical interface that allows users to either upload their own background image or select from three predefined wallpapers.

You can find the complete script and image structure here:
SetWallpaper_20171004.

Script Features

    • Three predefined wallpapers
      Users can choose from three different built-in background images.
    • Upload custom wallpaper
      Users can upload and set their own background image.
    • Automatic thumbnail generation
      When a custom image is uploaded, the script automatically creates a base64-encoded thumbnail and stores it in the user’s roaming profile.
      (Why base64? Images are locked while the PowerShell form is active, preventing modification or deletion. Using a base64 representation allows the thumbnail to be updated dynamically while the form is still open.)
    • File size limitation
      Custom image uploads are restricted by a maximum file size defined in the script.
    • Graphical User Interface (GUI)
      A user-friendly interface makes selecting or uploading wallpapers easy and intuitive.
    • Adaptive resolution
      The script detects the current session’s screen resolution and selects the most suitable wallpaper version accordingly.

Simple and intuitive GUI

The graphical interface is clean, straightforward, and easy for users to navigate—no technical knowledge required.

The PowerShell GUI can be easily started through a desktop shortcut or a shortcut in the Start Menu for convenient user access.
Assistant to upload own background image/wallpaper.

Automatically generates a thumbnail of the uploaded image or wallpaper as a base64 file in the user’s roaming profile.
Thumbnail preview and set own background image/wallpaper.
File size limitation for uploaded images or wallpapers (the default limit is 1 MB, but this can be modified in the PowerShell script variables).
Includes three predefined background wallpapers to choose from.

OK, let’s get started…

Before using the PowerShell script, you’ll need to understand and define a few key variables. These variables determine the script’s behavior and resource locations:

$ProgramPath (script line 32)
Specifies the location of the PowerShell script.
(In this example, the script and image files are stored in the Program Files directory.)

$ProfilePath (script line 33)
Defines the path where user-uploaded wallpaper images and their generated base64 thumbnails will be saved.

$MaxFileLength (script line 34)
Sets the maximum allowed file size for uploaded images.

$WallpaperIcon (script line 37)
Specifies the filename of the icon displayed in the upper-left corner of the PowerShell GUI.

$WallpaperStyle (script line 38)
Determines how the wallpaper is displayed—either “Stretch” or “Center”.

$WallpaperPict1, $WallpaperPict2, $WallpaperPict3 (script lines 39–41)
Define the filenames of the three default wallpaper images available for user selection.

The PowerShell script

The script set your own uploaded or one of the three pre-defined background images/wallpaper on a Citrix published Desktop or Microsoft remote desktop.
Lines: 478

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
####################################################################################
#  Title:       Set wallpaper on Citrix RDS
#  Description: Set wallpaper in user session on Citrix RDS server and upload own
#               wallpaper
#  Version:     1.3/roe
#  Date/Time:   02.10.2017 / 21:24
#  Developer:   Beat
####################################################################################
#----------------------------------------------
# Collect and define data for form
#----------------------------------------------
function OnApplicationLoad {
return $true
}
function OnApplicationExit {
$script:ExitCode = 0
}

#----------------------------------------------
# Start function Generat form
#----------------------------------------------
function GenerateForm {
#Import form assemblies
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null

#***********************************************
#Define variables
#***********************************************
$UserName = $env:USERNAME
$ProgramPath = "c:\Program Files\CTXTools\Scripts\SetWallpaper"
$ProfilePath = "c:\Users\$UserName\AppData\Roaming"
$MaxFileLength = "1000kb"
$ThumbHeight = "152"
$ThumbLength = "95"
$WallpaperStyle = 2 #(Stretch=2, Center=1)
$WallpaperIcon = "wallpaper.ico"
$WallpaperPict1 = "wallpaperctx"
$WallpaperPict2 = "wallpapercompany"
$WallpaperPict3 = "wallpapercompany2"
#***********************************************

#Define thumbnail path
$WallpaperThumb1 = "thumb$WallpaperPict1.jpg"
$WallpaperThumb2 = "thumb$WallpaperPict2.jpg"
$WallpaperThumb3 = "thumb$WallpaperPict3.jpg"
$WallpaperThumbOwn = "thumb$WallpaperOwn.jpg"
$wallpaper1 = (get-item "$ProgramPath\pict\$WallpaperThumb1")
$wallpaper2 = (get-item "$ProgramPath\pict\$WallpaperThumb2")
$wallpaper3 = (get-item "$ProgramPath\pict\$WallpaperThumb3")
$WallpaperOwn = "wallpaperown"

#Define Citrix session ID
$keySessionnr = "HKCU:\SOFTWARE\Citrix\SessionSfr"
$CitrixSessionID = (Get-ChildItem -Path $keySessionnr -Name)

#Define Citrix session display resolution
$keyResolution = "HKLM:\SOFTWARE\Citrix\Ica\Session\$CitrixSessionID\Connection"
$CitrixDispHRes = (Get-ItemProperty -Path $keyResolution -Name "HRes" | Select -exp HRes)
$CitrixDispVRes = (Get-ItemProperty -Path $keyResolution -Name "VRes" | Select -exp VRes)

#Generated form objects
$Icon = New-Object system.drawing.icon ("$ProgramPath\pict\$WallpaperIcon")
$Font = New-Object System.Drawing.Font("Microsoft Sans Serif",10,[System.Drawing.FontStyle]::Regular)
$labelHead = New-Object System.Windows.Forms.Label
$img1 = [System.Drawing.Image]::Fromfile($wallpaper1);
$img2 = [System.Drawing.Image]::Fromfile($wallpaper2);
$img3 = [System.Drawing.Image]::Fromfile($wallpaper3);
$form1 = New-Object System.Windows.Forms.Form
$buttonupl = New-Object System.Windows.Forms.Button
$buttonimg1 = New-Object System.Windows.Forms.Button
$buttonimg2 = New-Object System.Windows.Forms.Button
$buttonimg3 = New-Object System.Windows.Forms.Button
$buttonimgOwn = New-Object System.Windows.Forms.Button
$label1 = New-Object System.Windows.Forms.Label
$label2 = New-Object System.Windows.Forms.Label
$labelupl = New-Object System.Windows.Forms.Label
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
$FontFoot = New-Object System.Drawing.Font("Microsoft Sans Serif",7,[System.Drawing.FontStyle]::Regular)
$labelFoot = New-Object System.Windows.Forms.Label

#Import own image from base64 code and generate form object
$base64ImageString = [IO.File]::ReadAllText("$ProfilePath\wallpaperownthumb.txt")
$imageBytes = [Convert]::FromBase64String($base64ImageString)
$ms = New-Object IO.MemoryStream($imageBytes, 0, $imageBytes.Length)
$ms.Write($imageBytes, 0, $imageBytes.Length);
$imgOwn = [System.Drawing.Image]::FromStream($ms, $true)

#----------------------------------------------
# Call "set wallpaper" function
#----------------------------------------------
#Define script blocks for function "set wallpaper"
$ScriptBlockWallpaperAPI = {
Add-Type @"
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace Wallpaper
{
public enum Style : int
{
Tile, Center, Stretch, NoChange
}
public class Setter {
public const int SetDesktopWallpaper = 20;
public const int UpdateIniFile = 0x01;
public const int SendWinIniChange = 0x02;
[DllImport("
user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SystemParametersInfo (int uAction, int uParam, string lpvParam, int fuWinIni);
public static void SetWallpaper ( string path, Wallpaper.Style style ) {
SystemParametersInfo( SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange );
RegistryKey key = Registry.CurrentUser.OpenSubKey("
Control Panel\\Desktop", true);
switch( style )
{
case Style.Stretch :
key.SetValue(@"
WallpaperStyle", "2") ;
key.SetValue(@"
TileWallpaper", "0") ;
break;
case Style.Center :
key.SetValue(@"
WallpaperStyle", "1") ;
key.SetValue(@"
TileWallpaper", "0") ;
break;
case Style.Tile :
key.SetValue(@"
WallpaperStyle", "1") ;
key.SetValue(@"
TileWallpaper", "1") ;
break;
case Style.NoChange :
break;
}
key.Close();
}
}
}
"
@
#End ScriptBlockWallpaperAPI
}

$ScriptBlockSetWallpaper = {param ($WallpaperPict)
If ($CitrixDispHRes -lt 2561)
{
If ($CitrixDispHRes -lt 1921)
{
If ($CitrixDispHRes -lt 1681)
{
If ($CitrixDispHRes -lt 1441)
{
[Wallpaper.Setter]::SetWallpaper( "$ProgramPath\pict\$WallpaperPict"+"_1440_900.jpg", $WallpaperStyle )
Write-Host "1440_900"
}
else
{
[Wallpaper.Setter]::SetWallpaper( "$ProgramPath\pict\$WallpaperPict"+"_1680_1050.jpg", $WallpaperStyle )
Write-Host "1680_1050"
}
}
else
{
[Wallpaper.Setter]::SetWallpaper( "$ProgramPath\pict\$WallpaperPict"+"_1920_1200.jpg", $WallpaperStyle )
Write-Host "1920_1200"
}

}
else
{
[Wallpaper.Setter]::SetWallpaper( "$ProgramPath\pict\$WallpaperPict"+"_2560_1440.jpg", $WallpaperStyle )
Write-Host "2560_1440"
}
}
else
{
[Wallpaper.Setter]::SetWallpaper( "$ProgramPath\pict\$WallpaperPict"+"_2560_1440.jpg", $WallpaperStyle )
}
#End ScriptBlockSetWallpaper
}

function wallpaperOwn {
& $ScriptBlockWallpaperAPI
[Wallpaper.Setter]::SetWallpaper( "$ProfilePath\$WallpaperOwn.jpg", $WallpaperStyle )
}

function wallpaper1 {
& $ScriptBlockWallpaperAPI
& $ScriptBlockSetWallpaper -WallpaperPict $WallpaperPict1
}

function wallpaper2 {
& $ScriptBlockWallpaperAPI
& $ScriptBlockSetWallpaper -WallpaperPict $WallpaperPict2
}

function wallpaper3 {
& $ScriptBlockWallpaperAPI
& $ScriptBlockSetWallpaper -WallpaperPict $WallpaperPict3
}

#----------------------------------------------
# Call "make thumb" function
#----------------------------------------------
function makethumb
{
Param([Parameter(Mandatory=$true)][string]$InputFile, [string]$OutputFile, [int32]$Width, [int32]$Height, [int32]$Scale, [Switch]$Display)

#Add system drawing assembly
Add-Type -AssemblyName System.Drawing

#Open image file
$img = [System.Drawing.Image]::FromFile((Get-Item $InputFile))

#Define new resolution
if($Width -gt 0) { [int32]$new_width = $Width }
elseif($Scale -gt 0) { [int32]$new_width = $img.Width * ($Scale / 100) }
else { [int32]$new_width = $img.Width / 2 }
if($Height -gt 0) { [int32]$new_height = $Height }
elseif($Scale -gt 0) { [int32]$new_height = $img.Height * ($Scale / 100) }
else { [int32]$new_height = $img.Height / 2 }

#Create empty canvas for the new image
$img2 = New-Object System.Drawing.Bitmap($new_width, $new_height)

#Draw new image on the empty canvas
$graph = [System.Drawing.Graphics]::FromImage($img2)
$graph.DrawImage($img, 0, 0, $new_width, $new_height)

#Create window to display the new image
if($Display)
{
Add-Type -AssemblyName System.Windows.Forms
$win = New-Object Windows.Forms.Form
$box = New-Object Windows.Forms.PictureBox
$box.Width = $new_width
$box.Height = $new_height
$box.Image = $img2
$win.Controls.Add($box)
$win.AutoSize = $true
$win.ShowDialog()
}

#Save the image
if($OutputFile -ne "")
{
$img2.Save($OutputFile);
}
}

#----------------------------------------------
# Call "upload own wallpaper" function
#----------------------------------------------
function wallpaperupload($initialDirectory)
{
#Remove previous image
Remove-Item "$ProfilePath\$WallpaperOwn.jpg" -force
Remove-Item "$ProfilePath\wallpaperownthumb.txt" -force

#Create new file dialog
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.initialDirectory = $initialDirectory
$OpenFileDialog.filter = “All files (*.jpg)| *.jpg”
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.filename
$Fileuplname = $OpenFileDialog.filename

#Open walpaperupload handle and check file length
if ((Get-Item $Fileuplname).length -lt $MaxFileLength)
{
Copy-Item "$Fileuplname" -Destination "$ProfilePath\$WallpaperOwn.jpg"
makethumb -InputFile "$ProfilePath\$WallpaperOwn.jpg" -Width $ThumbHeight -Height $ThumbLength -OutputFile "$ProfilePath\$WallpaperThumbOwn"
[convert]::ToBase64String((Get-Content "$ProfilePath\$WallpaperThumbOwn" -Encoding byte))>>"$ProfilePath\wallpaperownthumb.txt"
Remove-Item "$ProfilePath\$WallpaperThumbOwn" -force
}
else
{
Add-Type -AssemblyName PresentationCore,PresentationFramework
[System.Windows.Forms.MessageBox]::Show("The file size exceeds the maximum size of 1MB.","File size exceeded",0,[System.Windows.Forms.MessageBoxIcon]::Error)
}

$form1.Dispose()
GenerateForm
}

#----------------------------------------------
# Call "form functions" from button click
#----------------------------------------------
#Call funtion from ButtonUpload
$handler_buttonupl_Click= ${function:wallpaperupload}
{

#Call funtion from ButtonOwn
}
$handler_buttonOwn_Click= ${function:wallpaperOwn}
{

#Call funtion from Button1
}
$handler_button1_Click= ${function:wallpaper1}
{

#Call funtion from Button2
}
$handler_button2_Click= ${function:wallpaper2}
{

#Call funtion from Button3
}
$handler_button3_Click= ${function:wallpaper3}
{
}

#----------------------------------------------
# Form code to generate gui
#----------------------------------------------
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 373
$System_Drawing_Size.Width = 516
$form1.Icon = $Icon
$form1.Font = $Font
$form1.ClientSize = $System_Drawing_Size
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$form1.Name = "form1"
$form1.Text = "Set Wallpaper"
$form1.FormBorderStyle = "Fixed3D"

$labelHead.Text = "To set a wallpaper on your published Desktop, choose a default wallpaper or upload your own wallpaper."
$labelHead.Location = "15, 15"
$labelHead.Height = 45
$labelHead.Width = 330

$buttonupl.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonupl.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,1,3,1)
$buttonimgOwn.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonimgOwn.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,1,3,1)
$buttonimg1.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonimg1.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,1,3,1)
$buttonimg2.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonimg2.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,1,3,1)
$buttonimg3.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonimg3.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,1,3,1)

$System_Drawing_Upload = New-Object System.Drawing.Point
$System_Drawing_Upload.X = 15
$System_Drawing_Upload.Y = 65
$buttonupl.Location = $System_Drawing_Upload
$buttonupl.Name = "Wallpaper1"
$System_Drawing_Upload = New-Object System.Drawing.Size
$System_Drawing_Upload.Height = 49
$System_Drawing_Upload.Width = 152
$buttonupl.Size = $System_Drawing_Upload
$buttonupl.TabIndex = 0
$buttonupl.Text = "Upload..."
$buttonupl.UseVisualStyleBackColor = $True
$buttonupl.add_Click($handler_buttonupl_Click)

$labelupl.Text = "Max file size: 1MB"
$labelupl.Location = "15, 128"
$labelupl.Height = 20
$labelupl.Width = 250

$label1.Text = "Citrix Session Resolution: $CitrixDispHRes/$CitrixDispVRes"
$label1.Location = "15, 143"
$label1.Height = 20
$label1.Width = 250

$System_Drawing_PointOwn = New-Object System.Drawing.Point
$System_Drawing_PointOwn.X = 350
$System_Drawing_PointOwn.Y = 128
$buttonimgOwn.Location = $System_Drawing_PointOwn
$buttonimgOwn.Name = "Wallpaper1"
$System_Drawing_SizeOwn = New-Object System.Drawing.Size
$System_Drawing_SizeOwn.Height = 49
$System_Drawing_SizeOwn.Width = 152
$buttonimgOwn.Size = $System_Drawing_SizeOwn
$buttonimgOwn.TabIndex = 0
$buttonimgOwn.Text = "Own Wallpaper"
$buttonimgOwn.UseVisualStyleBackColor = $True
$buttonimgOwn.add_Click($handler_buttonOwn_Click)

$pictureBoxOwn = new-object Windows.Forms.PictureBox
$pictureBoxOwn.Location = "350, 15"
$pictureBoxOwn.Height = 95
$pictureBoxOwn.Width = 152
$pictureBoxOwn.Image = $imgOwn;

$pictureBox1 = new-object Windows.Forms.PictureBox
$pictureBox1.Location = "15, 189"
$pictureBox1.Height = $img1.Size.Height
$pictureBox1.Width = $img1.Size.Width
$pictureBox1.Image = $img1

$System_Drawing_Point1 = New-Object System.Drawing.Point
$System_Drawing_Point1.X = 15
$System_Drawing_Point1.Y = 302
$buttonimg1.Location = $System_Drawing_Point1
$buttonimg1.Name = "Wallpaper1"
$System_Drawing_Size1 = New-Object System.Drawing.Size
$System_Drawing_Size1.Height = 49
$System_Drawing_Size1.Width = 152
$buttonimg1.Size = $System_Drawing_Size1
$buttonimg1.TabIndex = 0
$buttonimg1.Text = "Wallpaper Citrix"
$buttonimg1.UseVisualStyleBackColor = $True
$buttonimg1.add_Click($handler_button1_Click)

$pictureBox2 = new-object Windows.Forms.PictureBox
$pictureBox2.Location = "182, 189"
$pictureBox2.Height = $img2.Size.Height
$pictureBox2.Width = $img2.Size.Width
$pictureBox2.Image = $img2

$System_Drawing_Point2= New-Object System.Drawing.Point
$System_Drawing_Point2.X = 182
$System_Drawing_Point2.Y = 302
$buttonimg2.Location = $System_Drawing_Point2
$buttonimg2.Name = "Wallpaper2"
$System_Drawing_Size2 = New-Object System.Drawing.Size
$System_Drawing_Size2.Height = 49
$System_Drawing_Size2.Width = 152
$buttonimg2.Size = $System_Drawing_Size2
$buttonimg2.TabIndex = 0
$buttonimg2.Text = "Wallpaper fresh-it"
$buttonimg2.UseVisualStyleBackColor = $True
$buttonimg2.add_Click($handler_button2_Click)

$pictureBox3 = new-object Windows.Forms.PictureBox
$pictureBox3.Location = "350, 189"
$pictureBox3.Height = $img3.Size.Height
$pictureBox3.Width = $img3.Size.Width
$pictureBox3.Image = $img3

$System_Drawing_Point3= New-Object System.Drawing.Point
$System_Drawing_Point3.X = 350
$System_Drawing_Point3.Y = 302
$buttonimg3.Location = $System_Drawing_Point3
$buttonimg3.Name = "Wallpaper3"
$System_Drawing_Size3 = New-Object System.Drawing.Size
$System_Drawing_Size3.Height = 49
$System_Drawing_Size3.Width = 152
$buttonimg3.Size = $System_Drawing_Size3
$buttonimg3.TabIndex = 0
$buttonimg3.Text = "Wallpaper fresh-it-Logo"
$buttonimg3.UseVisualStyleBackColor = $True
$buttonimg3.add_Click($handler_button3_Click)

$labelFoot.Font = $FontFoot
$labelFoot.Text = "fresh-it.info (c) | support@fresh-it.info | Ver. 1.3/roe"
$labelFoot.Location = "15, 355"
$labelFoot.Height = 40
$labelFoot.Width = 250

$form1.Controls.Add($labelHead)
$form1.Controls.Add($label1)
$form1.Controls.Add($buttonupl)
$form1.Controls.Add($labelupl)
$form1.Controls.Add($buttonimgOwn)
$form1.Controls.Add($pictureBox1)
$form1.Controls.Add($pictureBox2)
$form1.Controls.Add($pictureBox3)
$form1.Controls.Add($pictureBoxOwn)
$form1.Controls.Add($buttonimg1)
$form1.Controls.Add($buttonimg2)
$form1.Controls.Add($buttonimg3)
$form1.Controls.Add($labelFoot)

#Save state of the form
$InitialFormWindowState = $form1.WindowState

#Correct OnLoad event to correct form state
$form1.add_Load($form1_StateCorrection_Load)

#Display defined form
return $form1.ShowDialog()
}

#Call function GenerateForm
if(OnApplicationLoad -eq $true)
{
GenerateForm | Out-Null
OnApplicationExit
}
####################################################################################

Citrix – NetScaler VPN Portal Homepage – Storefront Refused Connection with X1 Theme

Summary

Your company uses SSL VPN via Citrix NetScaler to provide secure access for employees and customers. When users connect, they are presented with the VPN portal homepage, styled with the X1 theme.

From the portal menu, clicking the “Citrix Applications” link is intended to open the Citrix Receiver page, as defined in the session profile. However, when using Microsoft Edge (Chromium-based), the Citrix Receiver page fails to load or is refused.

Description

When accessing Citrix StoreFront through the Citrix NetScaler VPN portal homepage (configured with the X1 theme), the X-Frame-Options settings in StoreFront may block the HTTP request from the Microsoft Edge (Chromium)browser.

Even if you’ve followed the guidance in Citrix article CTX202890, the frame-ancestors directive provided in the article does not fully resolve the issue when used with Microsoft Edge Chromium in combination with the X1 theme.

To fix this, you need to supplement the frame-ancestors directive with the FQDN of the StoreFront server, or include the domain and top-level domain of your internal environment.
Using wildcards in the frame-ancestors value is also supported and, in most cases, provides the simplest and most flexible solution—without compromising the security of IIS or Edge.

To verify the issue, you can use the Developer Tools in Microsoft Edge Chromium to inspect the HTTP response and view the specific refused request error.

Configuring the

1
web.config

File in Citrix StoreFront

To resolve the frame blocking issue, open the web.config file for the affected StoreFront Web Store located at:
C:\inetpub\wwwroot\Citrix\StoreWeb\web.config

Search for the X-Frame-Options or Content-Security-Policy directive.

    1. Locate the frame-ancestors setting.
    2. Add your StoreFront FQDN or your top-level domain to the
    3. frame-ancestors value, as shown in the example or screenshot.

Example:
Content-Security-Policy: frame-ancestors ‘self’ https://storefront.yourdomain.com

You can also use wildcards for flexibility, depending on your environment and security requirements.

This configuration ensures proper loading of the StoreFront page within the Citrix NetScaler VPN portal—especially when using the X1 theme and Microsoft Edge Chromium.

frame-ancestors with Storefront FQDN configuration in the X-Frame-Options

frame-ancestors with wildcard domain and top level configuration in the X-Frame-Options

With the configured frame-ancestors in the X-Frame-Options, the Storefront Receiver page will be no longer refused.

Citrix – Microsoft Edge Chromium Prompt To Run nglauncher.exe (Citrix NetScaler Plugin)

Summary

When logging in to Citrix NetScaler Gateway with Citrix VPN configured, Microsoft Edge prompts the user to run nglauncher.exe (Citrix NetScaler Plugin).
The following instructions provide a solution to properly configure Microsoft Edge Chromium to handle this prompt.

Description

To identify the required configuration values, you need to analyze the communication between Microsoft Edge Chromium and the Citrix NetScaler Gateway. In this example, the analysis was performed using Microsoft Edge Developer Tools.

During login, you can observe the nglauncher.exe call in the HTTP request headers of the Citrix NetScaler page.
The “Request URL:” field contains the key information needed for the configuration steps that follow.

You can apply this configuration either:

    • Globally via Group Policy (using the Microsoft Edge Chromium ADMX templates), or
    • Locally by modifying the Windows Registry on the user’s device.

GPO Configuration

The following Group Policy setting must be configured to suppress the Microsoft Edge Chromium prompt.

GPO Setting: Define a list of allowed URLs
GPO Setting Path: User Configuration\Policies\Administrative Templates\Microsoft Edge\
Value:citrixng://*


Registry Configuration

The following registry setting must be applied to bypass the Microsoft Edge Chromium prompt.

Registry Hive: HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
Registry Path: Software\Policies\Microsoft\Edge\URLAllowlist
Registry Value Name: {number} **
Registry Value Type: REG_SZ
Registry Value: citrixng://*

** The Value consists of a number, if an value already exists, the entry to be configured must have a sequence number.