Forum Discussion

Jesse13579's avatar
Jesse13579
Brass Contributor
Jul 26, 2024
Solved

Using intune to create application desktop shortcuts

I'm trying to use intune to push an application shortcut to the public desktop.  I created an lnk file and saved it to a shared network drive.  I then wrote a powershell script to copy that file to a folder on the c drive of the pc and then form that folder to the public desktop.  Here is the script

 

------------------------------------------------------------------------------------------------------------------

#Create directory to hold icon file and copy file there
New-Item -Path "c:\" -Name "scut" -ItemType "directory" -Force
Copy-Item "S:\Shortcuts\PS1 Files\Fortinet Icon\FortiClientVPN.lnk" -Destination "c:\scut\FortiClientVPN.lnk"

$TargetFile = "c:\scut\FortiClientVPN.lnk"
$ShortcutFile = "$env:Public\Desktop\FortiClientVPN.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.Save()

 

------------------------------------------------------------------------------------------------------------

I wrapped the script with intunewinapp utility and created a win32 app with the file.  I use this as my install command. (forti2.ps1 is my original powershell file)

--------------------------------------------------------------------------------------------------------------

powershell.exe -ExecutionPolicy Bypass -file forti2.ps1

 

---------------------------------------------------------------------------------------------------------------

 

My detection rule is just a custom rule that looks for the file on the desktop.  When the app runs I get

"The application was not detected after installation completed successfully (0x87D1041C)" error.  Any ideas what I'm missing?

 

  • You should include the .lnl file in the Win32 app and use :
    Copy-Item ".\FortiClientVPN.lnk" -Destination "c:\scut\FortiClientVPN.lnk"
    Copy-Item ".\FortiClientVPN.lnk" -Destination "$env:Public\Desktop\FortiClientVPN.lnk"

    But is there a reason for it to be on c:\scut and the Public Desktop? You created the shortcut on the Public Desktop based on the copied from S:\, but that drive is unavailable when installed as a System. I think adding the shortcut file to your package and copying it just to the public desktop is enough?

5 Replies

  • StableGuy's avatar
    StableGuy
    Copper Contributor

    So your files are copied, or ...?

    I didn't check your script, but Harm may found something, but the trigger for me is the Network share.
    When you run this under System, your network share is probably not accessible and you should use the Run as User option. (also as Harm mentioned...)

    • The mapping is a problem; it's not accessible running it as a user, too, I guess, because it doesn't do any mapping.

      Just run the script as system and include the .lnk file in the package.
  • You should include the .lnl file in the Win32 app and use :
    Copy-Item ".\FortiClientVPN.lnk" -Destination "c:\scut\FortiClientVPN.lnk"
    Copy-Item ".\FortiClientVPN.lnk" -Destination "$env:Public\Desktop\FortiClientVPN.lnk"

    But is there a reason for it to be on c:\scut and the Public Desktop? You created the shortcut on the Public Desktop based on the copied from S:\, but that drive is unavailable when installed as a System. I think adding the shortcut file to your package and copying it just to the public desktop is enough?

Resources