Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut "Start in" property points to incorrect path after update #1805

Open
Slipheed opened this issue May 18, 2022 · 2 comments
Open

Shortcut "Start in" property points to incorrect path after update #1805

Slipheed opened this issue May 18, 2022 · 2 comments

Comments

@Slipheed
Copy link

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:

image

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

  1. Deploy initial App (releasify, users download and install)
  2. Update App (releasify, user receives update)
  3. User right-clicks desktop icon, selects properties, then clicks on Compatibility tab to select Run as Admin
  4. Error message appears
  5. Check "Start in" property and the path is pointing to "app-1.0.0", which no longer exist (deleted as normal process of Squirrel update)

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.

@Slipheed
Copy link
Author

Slipheed commented Jul 23, 2022

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);
           }
       }

@eliw00d
Copy link

eliw00d commented Dec 21, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants