mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-26 07:05:52 -05:00
Fixed opendeskurl() so that the created task can work on battery power
This commit is contained in:
parent
7d28a0648e
commit
b1e11e0410
@ -2624,13 +2624,30 @@ function openUserDesktopUrl(url) {
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
var user = require('user-sessions').getUsername(require('user-sessions').consoleUid());
|
||||
child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['cmd']);
|
||||
child.stderr.on('data', function () { });
|
||||
child.stdout.on('data', function () { });
|
||||
child.stdin.write('SCHTASKS /CREATE /F /TN MeshChatTask /SC ONCE /ST 00:00 /RU "' + user + '" /TR "' + process.env['windir'] + '\\system32\\cmd.exe /C START ' + url.split('&').join('^&') + '"\r\n');
|
||||
var taskoptions = { env: { _target: process.env['windir'] + '\\system32\\cmd.exe', _args: '/C START ' + url.split('&').join('^&'), _user: '"' + user + '"' } };
|
||||
for (var c1e in process.env)
|
||||
{
|
||||
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);
|
||||
child.stderr.on('data', function (c) { });
|
||||
child.stdout.on('data', function (c) { });
|
||||
child.stdin.write('SCHTASKS /CREATE /F /TN MeshChatTask /SC ONCE /ST 00:00 ');
|
||||
if (user) { child.stdin.write('/RU $env:_user '); }
|
||||
child.stdin.write('/TR "$env:_target $env:_args"\r\n');
|
||||
child.stdin.write('$ts = New-Object -ComObject Schedule.service\r\n');
|
||||
child.stdin.write('$ts.connect()\r\n');
|
||||
child.stdin.write('$tsfolder = $ts.getfolder("\\")\r\n');
|
||||
child.stdin.write('$task = $tsfolder.GetTask("MeshChatTask")\r\n');
|
||||
child.stdin.write('$taskdef = $task.Definition\r\n');
|
||||
child.stdin.write('$taskdef.Settings.StopIfGoingOnBatteries = $false\r\n');
|
||||
child.stdin.write('$taskdef.Settings.DisallowStartIfOnBatteries = $false\r\n');
|
||||
child.stdin.write('$taskdef.Actions.Item(1).Path = $env:_target\r\n');
|
||||
child.stdin.write('$taskdef.Actions.Item(1).Arguments = $env:_args\r\n');
|
||||
child.stdin.write('$tsfolder.RegisterTaskDefinition($task.Name, $taskdef, 4, $null, $null, $null)\r\n');
|
||||
|
||||
child.stdin.write('SCHTASKS /RUN /TN MeshChatTask\r\n');
|
||||
child.stdin.write('SCHTASKS /DELETE /F /TN MeshChatTask\r\n');
|
||||
child.stdin.write('exit\r\n');
|
||||
child.stdin.write('SCHTASKS /DELETE /F /TN MeshChatTask\r\nexit\r\n');
|
||||
child.waitExit();
|
||||
break;
|
||||
case 'linux':
|
||||
|
Loading…
Reference in New Issue
Block a user