Skip to content

Desktop shortcut - System.ArgumentException: Illegal characters in path #1319

Open
@zJesusJavier

Description

@zJesusJavier

Hi! I'm installing my Electron app but I have this problem, the desktop shortcut is no longer being created, It was working fine a couple of hours before, but now I'm getting this error:

SquirrelSetup.log

2018-05-16 19:43:22> Program: Starting Squirrel Updater: --createShortcut ERCGK.exe
2018-05-16 19:43:22> ApplyReleasesImpl: About to create shortcuts for ERCGK.exe, rootAppDir C:\Users\SoulO\AppData\Local\ercgk
2018-05-16 19:43:23> Unhandled exception: System.ArgumentException: Illegal characters in path.
   at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
   at System.IO.Path.Combine(String path1, String path2, String path3)
   at Squirrel.UpdateManager.ApplyReleasesImpl.getLinkTarget(ShortcutLocation location, String title, String applicationName, Boolean createDirectoryIfNecessary)
   at Squirrel.UpdateManager.ApplyReleasesImpl.linkTargetForVersionInfo(ShortcutLocation location, IPackage package, FileVersionInfo versionInfo)
   at Squirrel.UpdateManager.ApplyReleasesImpl.CreateShortcutsForExecutable(String exeName, ShortcutLocation locations, Boolean updateOnly, String programArguments, String icon)
   at Squirrel.Update.Program.Shortcut(String exeName, String shortcutArgs, String processStartArgs, String icon)
   at Squirrel.Update.Program.executeCommandLine(String[] args)
   at Squirrel.Update.Program.main(String[] args)

main.js

const electron = require('electron')
const app = electron.app

if (handleSquirrelEvent(app)) 
{
    return;
}

const BrowserWindow = electron.BrowserWindow
const path = require('path')
const url = require('url')

let mainWindow

function createWindow() 
{
    mainWindow = new BrowserWindow(
	{
        movable: false,
        transparent: true,
        icon: path.join(__dirname, 'img/favicon.png'),
        
	})

    mainWindow.maximize()
    mainWindow.show()
    mainWindow.loadURL(`file://${__dirname}/load.html`)
	mainWindow.on('closed', function() 
	{
        mainWindow = null
    })
}

app.on('ready', createWindow)

app.on('window-all-closed', function() 
{
	if (process.platform !== 'darwin') 
	{
        app.quit()
    }
})

app.on('activate', function() 
{
	if (mainWindow === null) 
	{
        createWindow()
    }
})

function handleSquirrelEvent(application) {
    if (process.argv.length === 1) {
        return false;
    }

    const ChildProcess = require('child_process');
    const path = require('path');

    const appFolder = path.resolve(process.execPath, '..');
    const rootAtomFolder = path.resolve(appFolder, '..');
    const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
    const exeName = path.basename(process.execPath);

    const spawn = function(command, args) {
        let spawnedProcess, error;

        try {
            spawnedProcess = ChildProcess.spawn(command, args, {
                detached: true
            });
        } catch (error) {}

        return spawnedProcess;
    };

    const spawnUpdate = function(args) {
        return spawn(updateDotExe, args);
    };

    const squirrelEvent = process.argv[1];
    switch (squirrelEvent) {
        case '--squirrel-install':
        case '--squirrel-updated':

            spawnUpdate(['--createShortcut', exeName]);

            setTimeout(application.quit, 1000);
            return true;

        case '--squirrel-uninstall':

            spawnUpdate(['--removeShortcut', exeName]);

            setTimeout(application.quit, 1000);
            return true;

        case '--squirrel-obsolete':

            application.quit();
            return true;
    }
};

build.js

var electronInstaller = require('electron-winstaller');

resultPromise = electronInstaller.createWindowsInstaller({
    appDirectory: './ERCGK-win32-x64',
    outputDirectory: './ERCGK-Installers',
    authors: 'ERCGK',
    exe: './ERCGK.exe',
    setupExe: 'ERCGK.exe',
    noMsi: true,
    loadingGif: './ERCGK-win32-x64/resources/app/img/load.gif',
    setupIcon: './ERCGK-win32-x64/resources/app/img/icon.ico'
  });

resultPromise.then(() => console.log("Instalador creado."), (e) => console.log(`Error: ${e.message}`));

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:old-versionIssues that target a very old version of the library, and should be retested if possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions