Cross-platform shortcut to executable file, both archived

1

1

I have a directory (which is later archived) in which a shortcut to an executable file (.exe), which itself is a few directories deeper. The first problem encountered is ".lnk" shortcuts require exact path. E.g. "D:/someFolder/parentOfShortcut/files/dir/dir/dir/software.exe commandForTheExe" and if the directory parentOfShortcut is moved to the root (for example), the shortcut will be still looking for the app in "D:/someFolder/parentOf...". I thought of using a ".bat" file, however, that's a Windows-only solution, while the app itself is compatible also with both Linux and MacOS. The second problem of the ".bat" is that users never trust that type of files so does any antivirus software.

It is a quandary that the location of parentOfShortcut can be anywhere since users download that folder (as a .zip archive) and are free to save it in any given directory on their machine.

For reference, here's the exact file structure

(unknown path)/MySoftware(.zip)
    +- Shortcut.lnk
    |- files
        |- node_modules
            |- dist
                +- theApp.exe (with command "boot.main")

Edit:

The .exe can't be moved, for it depends on .dll files in the same, in the upper and in some lower-level directories.

Zefir Zdravkov

Posted 2018-09-05T06:49:17.830

Reputation: 61

How is the app itself cross-platform? Mac apps tend to be bundles with the executable at a given level, myApp.app/Contents/MacOs/myApp so should always 'know where they are'. – Tetsujin – 2018-09-05T07:04:32.510

@Tetsujin The path is not really unknown; it depends on where the user installs the archive. – Zefir Zdravkov – 2018-09-05T07:10:53.607

apps go in /Applications usually or for single user ~/Applications. Finder will know where it is anyway. They are normally delivered as ,dmg files with a handy drag & drop to Apps, unless they need an installer & elevated permissions. – Tetsujin – 2018-09-05T07:13:09.490

@Tetsujin I am not personally a macOS user, but the application (Electron) claims to be executable and fully functioning under that platform. – Zefir Zdravkov – 2018-09-05T07:15:30.673

You could use a ".bat" file for Windows and other scripts for Linux & Mac. But the usual solution is to have a platform-dependent installation script that will create the link. – harrymc – 2018-09-05T07:18:54.883

looks like some javascript thing. way outside my area of expertise & something you should be asking about in stack overflow. Anyway... there's no such thing as a cross-platform 'shortcut' - Mac can't parse .lnk files & Win doesn't know what to do with an alias – Tetsujin – 2018-09-05T07:20:31.827

@harrymc The platform-dependent installation will have to be in this case just because of the shortcut since the .exe itself is cross-platform executable. – Zefir Zdravkov – 2018-09-05T07:20:53.377

@PimpJuiceIT the exe is by a verified publisher: GitHub – Zefir Zdravkov – 2018-09-08T04:44:05.053

@PimpJuiceIT the exe is by GitHub (and Google apart) and the users download it from my website, not github.com or google.com because the .zip includes files and additional software I produce. If you downloaded Chrome from un unknown publisher, would you execute some .bat from the root? I wouldn't, but I'd certainly run a shortcut to the app itself, because what harm could it do? – Zefir Zdravkov – 2018-09-13T10:07:44.743

No worries, do what you wish and good luck!! As an FYI, there are many zip packages that include batch scripts that run optionally as-needed post extraction for various reasons so what I suggested is what I've seen included with many packages as you describe. I'm more of an admin than a package developer so only suggested what I consider "normal and typical" from my years working on many projects as such at the level of systems and packages I've had to deal with for various companies and industries. You can open a bat file and see it's logic/contents whereas you cannot with an exe like that. – Pimp Juice IT – 2018-09-13T12:24:19.883

Answers

1

I'm not a user of Electron, but here are some some resources I collected.

For creating desktop shortcuts you would need an installation program. There are a couple of such cross-platform products that are said to be capable of this, although it's somewhat unclear how well they works on the various platforms.

Not being a user of Electron, I can't test these products, but can contribute these details.

For electron-builder, one Github post says :

Set createDesktopShortcut to always.

"nsis": {
      "createDesktopShortcut": "always"
    }

Whether to create desktop shortcut. Set to always if to recreate also on reinstall (even if removed by user).

A StackOverflow post contains various advice, but adds this specifically for electron-forge apparently for Windows:

you may want to try a config that looks like this :

"electronPackagerConfig": {
  "icon": "Icon",
  "win32metadata":{
    "ProductName": "My App",
    "CompanyName": "My Company"
  }
}

More info here: https://github.com/electron-userland/electron-forge/issues/89

Another answer in the same post adds this for electron-builder :

Try to use electron-builder if you get painful with Squirrel. You can use the command as below to make your installer for Windows: electron-builder path/to/your-electron-packager-output --platform=win --out=path/to/your-installer-output --config=path/to/builder.json --target=win

Sample content for builder.json:

{ "win": { "title": "My Production Name", "icon": "path/to/your-icon.ico", "version": "1.0.0", "publisher": "Your Company Name" } }

P.s: You must install NSIS and add NSIS path into PATH environment before you run the above command.

Have a look at this other StackOverflow post Creating a desktop shortcut via Squirrel events with Electron that seems worth reading, since it shows a procedure that is reported as working.

You could on the other hand refrain from using any of the electron packagers and do it yourself with a proven cross-platform installer, such as the following:

I hope that this can get you started. Don't assume that any of the electron package builders will work for all operating systems, so you might need more than one. Test everything, assume nothing, is my advice.

harrymc

Posted 2018-09-05T06:49:17.830

Reputation: 306 093

It all seems solid, alas, I am having problems with my Internet and am therefore unable to check the resources you provided. I will make sure to review that tomorrow (Friday). – Zefir Zdravkov – 2018-09-13T10:13:33.687

I think you forgot me. – harrymc – 2018-09-15T18:58:10.760