> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.trugrid.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Publishing File Explorer as an app in TruGrid

Due to limitations of .bat and .lnk files, the solution that works is a small launcher program that has the folder built into it, with a Start Menu shortcut pointing at that launcher. No command line involved, so nothing gets lost when it's published.

## The script

You can create this shortcut by running this script on the RemoteApp server, in an elevated PowerShell session. Edit the four variables at the top if you want something other than the defaults.

powershell
```javascript
#requires -RunAsAdministrator
# Publishes a Start Menu app that opens File Explorer at a set folder.
# Compiles a small launcher using csc.exe, which is already on the server as
# part of .NET Framework. Nothing is downloaded. The launcher does one thing:
# run explorer.exe against $TargetFolder. Its full source is printed at the end
# so you can read exactly what went into it.

$TargetFolder = "C:\Users\Public\Desktop"   # folder the app opens
$IconSource   = "C:\Windows\explorer.exe"   # any .exe, .dll or .ico
$Name         = "Shortcut Explorer"         # file name and published app name
$LauncherDir  = "C:\Temp"                   # where the launcher .exe is stored,
                                            # created if it doesn't exist

$dir = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs"
New-Item -ItemType Directory -Path $LauncherDir -Force | Out-Null

# grab the icon
Add-Type -AssemblyName System.Drawing
$ico = "$env:TEMP\$Name.ico"
$i = [System.Drawing.Icon]::ExtractAssociatedIcon($IconSource)
$fs = [System.IO.File]::Create($ico); $i.Save($fs); $fs.Close()

# the whole launcher, one line
$src = @"
class L { static void Main() { System.Diagnostics.Process.Start("explorer.exe", "\"$($TargetFolder.Replace('\','\\'))\""); } }
"@
$cs = "$env:TEMP\$Name.cs"
Set-Content -Path $cs -Value $src -Encoding ASCII -Force

# compile, windowless, icon embedded
& "$env:WINDIR\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /nologo /target:winexe `
  /win32icon:"$ico" /out:"$LauncherDir\$Name.exe" $cs

# shortcut for TruGrid to collect
$sh = New-Object -ComObject WScript.Shell
$lnk = $sh.CreateShortcut("$dir\$Name.lnk")
$lnk.TargetPath   = "$LauncherDir\$Name.exe"
$lnk.IconLocation = "$LauncherDir\$Name.exe,0"
$lnk.Description  = "Opens File Explorer at $TargetFolder"
$lnk.Save()

Test-Path "$LauncherDir\$Name.exe"
Get-Content $cs
$sh.CreateShortcut("$dir\$Name.lnk") | Select-Object TargetPath, IconLocation | Format-List
```

Two files come out of this:
| File | Location | Purpose |
| `Shortcut Explorer.exe` | `C:\Temp` (or your `$LauncherDir`) | the launcher |
| `Shortcut Explorer.lnk` | `C:\ProgramData\Microsoft\Windows\Start Menu\Programs` | what TruGrid publishes |

`C:\Program Files\TruGrid` only exists on servers running the TruGrid Sentry service. If your RDS server isn't the Sentry, use `C:\Temp` or any other path that suits you. The launcher can live anywhere except `C:\Windows`.

## Publishing it

1. Run the script on the RDS server.
2. Double-click the new shortcut in the Start Menu folder to confirm it opens the folder you set.
3. In TruGrid, go to **Resource assignment** and refresh the app list. With Advanced publishing on, use **Manage app selection**, pick the server group, and tick the app.
4. Assign it to the users or groups that need it.

![](https://storage.crisp.chat/users/helpdesk/website/-/f/4/7/3/f473d72e7d7c5000/image_vxnon3.png)

If it doesn't appear, check the collection count on the Sentry server before anything else:

powershell
```
Get-Content "C:\Program Files\TruGrid\Sentry\Agent.LOG" -Tail 40 |
  Select-String "applications collected"
```

Refresh, run it again, compare the numbers. A count that goes up means the new shortcut was collected and the problem is in the selection screen. A count that stays the same means the shortcut wasn't picked up, and the thing to check is whether the file is really on the session host at the path above.

## Organising the shortcuts

The point of this is to give users one tile that lands them in a folder full of shortcuts, rather than publishing every application separately. `C:\Users\Public\Desktop` is a sensible target because it exists on every RDS server and all users can read it. Put subfolders in there, drop shortcuts into them, and users navigate from the one published tile.

## Two things to expect

**Antivirus.** The launcher is compiled fresh on your server and isn't signed. Some AV and EDR products quarantine unsigned binaries that launch Explorer. If that happens, add an exclusion for the `.exe` path.

**The icon.** The script sets the Explorer icon on both the shortcut and the launcher binary. Whether the published tile picks it up hasn't been confirmed on a live tenant yet. If the tile shows a generic icon, 
that's a display question on the TruGrid side, not a problem with the files.

To change the icon later, point `$IconSource` at any `.exe`, `.dll` or `.ico` and rerun the script. Same for the folder: change `$TargetFolder` and rerun. It overwrites cleanly both times.
