Electron Windows Installer未在桌面上创建快捷方式

时间:2018-06-28 22:09:57

标签: electron electron-packager squirrel.windows

尝试了许多时间和解决方案,但是都给了我同样的问题。一切正常,该应用程序正常运行,没有任何问题,只是桌面上没有创建快捷方式。我可以从日志文件“ EmulateFileIOPermissionChecks”中看到消息错误“不支持给定路径的格式”。但不知道这意味着什么。我在“电子松鼠启动”模块中遇到了相同的错误。这是与SquirrelSetup.log相关的情况

2018-06-28 17:56:15> Program: Starting Squirrel Updater: --createShortcut C:\Users\name\AppData\Local\myApp\app-0.1.0\myapp.exe
2018-06-28 17:56:15> ApplyReleasesImpl: About to create shortcuts for 
C:\Users\user\AppData\Local\myApp\app-0.1.0\myapp.exe, rootAppDir 
C:\Users\user\AppData\Local\idpAuthElectronApp 2018-06-28 17:56:15> Unhandled exception: System.NotSupportedException: The given path's format is not supported. atSystem.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath) at 
System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess 
access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean 
checkHost)
 at System.IO.Directory.CreateDirectory(String path)

这是我的代码:

var handleSquirrelEvent = function() {

if (process.platform != 'win32') {
  return false;
}

function executeSquirrelCommand(args, done) {
  var updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'update.exe');
  var child = cp.spawn(updateDotExe, args, { detached: true });

  child.on('close', function(code) {
     done();
  });
  };

function install(done) {
  var target = path.resolve(process.execPath);
  executeSquirrelCommand(['--createShortcut', target], done);
};

function uninstall(done) {
  var target = path.resolve(process.execPath);
  executeSquirrelCommand(["--removeShortcut", target], done);
};

var squirrelEvent = process.argv[1];

switch (squirrelEvent) {

  case '--squirrel-install':

     install(app.quit);

     return true;

  case '--squirrel-updated':

     install(app.quit);

     return true;

  case '--squirrel-obsolete':

     app.quit();

     return true;

  case '--squirrel-uninstall':
     uninstall(app.quit);
     return true;
}
 return false;
};

if (handleSquirrelEvent()) {
 return;
}

0 个答案:

没有答案