I've used C# and Powershell to create shortcuts, but when they are created in code they do not work. I click on the shortcut, the cursor shows the PC is thinking for a second and then nothing happens. This is the Powershell code I was using:
$currPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$tgtPath = ($currPath + "\bin\MyApp.exe")
$scutPath = ([Environment]::GetFolderPath("Desktop") + "\MyApp.lnk")
$wShell = New-Object -ComObject WScript.Shell
$scut = $wShell.CreateShortcut($scutPath)
$scut.TargetPath = $tgtPath
$scut.Save()
The C# code does essentially the same think using the IWshRuntimeLibrary. This little script basically just creates a shortcut on someone's desktop after they have downloaded my little standalone executable. I can manually create the shortcut and everything works fine. Why can't I do it through code?
I have created a few shortcuts and .url files on the desktop with the same name in the course of my testing, I'm not sure if that matters.