Fixed bug with long urls for openurl

This commit is contained in:
Bryan Roe 2022-02-03 15:14:35 -08:00
parent 93a6dd1b52
commit 45517db7dd
1 changed files with 36 additions and 23 deletions

View File

@ -3177,8 +3177,20 @@ function openUserDesktopUrl(url) {
var uid = require('user-sessions').consoleUid(); var uid = require('user-sessions').consoleUid();
var user = require('user-sessions').getUsername(uid); var user = require('user-sessions').getUsername(uid);
var domain = require('user-sessions').getDomain(uid); var domain = require('user-sessions').getDomain(uid);
var task = { name: 'MeshChatTask', user: user, domain: domain, execPath: process.env['windir'] + '\\system32\\cmd.exe', arguments: ['/C START ' + url.split('&').join('^&')] };
try
{
require('win-tasks').addTask(task);
require('win-tasks').getTask({ name: 'MeshChatTask' }).run();
require('win-tasks').deleteTask('MeshChatTask');
return (true);
}
catch(zz)
{
var taskoptions = { env: { _target: process.env['windir'] + '\\system32\\cmd.exe', _args: '/C START ' + url.split('&').join('^&'), _user: '"' + domain + '\\' + user + '"' } }; var taskoptions = { env: { _target: process.env['windir'] + '\\system32\\cmd.exe', _args: '/C START ' + url.split('&').join('^&'), _user: '"' + domain + '\\' + user + '"' } };
for (var c1e in process.env) { for (var c1e in process.env)
{
taskoptions.env[c1e] = process.env[c1e]; taskoptions.env[c1e] = process.env[c1e];
} }
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], taskoptions); var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], taskoptions);
@ -3201,6 +3213,7 @@ function openUserDesktopUrl(url) {
child.stdin.write('SCHTASKS /RUN /TN MeshChatTask\r\n'); child.stdin.write('SCHTASKS /RUN /TN MeshChatTask\r\n');
child.stdin.write('SCHTASKS /DELETE /F /TN MeshChatTask\r\nexit\r\n'); child.stdin.write('SCHTASKS /DELETE /F /TN MeshChatTask\r\nexit\r\n');
child.waitExit(); child.waitExit();
}
break; break;
case 'linux': case 'linux':
child = require('child_process').execFile('/usr/bin/xdg-open', ['xdg-open', url], { uid: require('user-sessions').consoleUid() }); child = require('child_process').execFile('/usr/bin/xdg-open', ['xdg-open', url], { uid: require('user-sessions').consoleUid() });