Open Slipheed opened 2 years ago
No one helped, so I eventually figured out a work around.
Maybe this will help someone else.
I placed this code after the App loaded. The AppNumber is a string that represents the Squirrel app version folder (i.e. app-1.0.0)
Assembly assembly = Assembly.GetExecutingAssembly();
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
string version = versionInfo.FileVersion;
if (MyApp.Version != version)
{
UpdateLinks(AppNumber);
MyApp.Version = version;
SaveSettings();
}
Helper Code to update the shortcuts correctly, which also sets Run As Administrator in the Advanced tab.
public void UpdateLinks(string StartInPath)
{
string DesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
string StartMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
string AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
WshShell shell = new WshShell();
object shDesktop = (object)"Desktop";
string daDesktopPath = (string)shell.SpecialFolders.Item(ref shDesktop) + @"\My App.lnk";
IWshShortcut NewDesktopShortcut = (IWshShortcut)shell.CreateShortcut(daDesktopPath);
NewDesktopShortcut.Description = "My App";
NewDesktopShortcut.WorkingDirectory = Path.Combine(AppDataPath + @"\MyApp\" + StartInPath);
NewDesktopShortcut.TargetPath = Path.Combine(AppDataPath + @"\MyApp\My App.exe");
NewDesktopShortcut.IconLocation = Path.Combine(AppDataPath + @"\MyApp\app.ico");
NewDesktopShortcut.Description = "The best app ever.";
NewDesktopShortcut.Save();
using (FileStream fs = new FileStream(daDesktopPath, FileMode.Open, FileAccess.ReadWrite))
{
fs.Seek(21, SeekOrigin.Begin);
fs.WriteByte(0x22);
}
object shStartMenu = (object)"StartMenu";
string StartMenuPath = (string)shell.SpecialFolders.Item(ref shStartMenu) + @"\My App.lnk";
IWshShortcut NewStartMenuShortcut = (IWshShortcut)shell.CreateShortcut(StartMenuPath);
NewStartMenuShortcut.Description = "My App";
NewStartMenuShortcut.WorkingDirectory = Path.Combine(AppDataPath + @"\App\" + StartInPath);
NewStartMenuShortcut.TargetPath = Path.Combine(AppDataPath + @"\MyApp\My App.exe");
NewStartMenuShortcut.IconLocation = Path.Combine(AppDataPath + @"\MyApp\app.ico");
NewStartMenuShortcut.Description = "The best app ever.";
NewStartMenuShortcut.Save();
using (FileStream fs = new FileStream(daStartMenuPath, FileMode.Open, FileAccess.ReadWrite))
{
fs.Seek(21, SeekOrigin.Begin);
fs.WriteByte(0x22);
}
}
I ran into something similar but my "Start in:" is completely garbled: ta\Local\MyApp\MyApp.exe8C:\Users\eliw00d\AppData\Local\MyApp\app-0.25
It should be: C:\Users\eliw00d\AppData\Local\MyApp\app-0.25.0
I am using Electron Forge and their Squirrel.Windows maker.
Squirrel version(s) 2.0.1
Description I discovered this issue after many updates successfully pushed to users. After pushing an update, some users need to set "Run AS administrator" in the Desktop icon Properties/Compatibility tab. If the compatibility Tab is selected, the following message appears:
Upon investigation, I noticed that the Desktop icon "Start In" property points to the initial build number folder. Example: Initial build folder is "app-1.0.0", and current (i.e. the last update pushed) build folder is "app-1.1.1".
Why is the "Start in" property pointing to the initial build folder (which no longer exists)?
Steps to recreate
Expected behavior The desktop icon Property "Start in" is updated when Squirrel updates the app.
Actual behavior App starts just fine, but if a user must select "Run as Administrator" in the Compatibility tab, they are presented with the error.
Additional information My App is setup per Documentation, is SquirrelAware, and the only thing I can think off is I change the the name of setup.exe to MyApp.exe. However, this is the name of the file since initial install.
Any help is greatly appreciated.