Updated 'openuserdesktopurl' so that on Windows, it uses the task scheduler to spawn the target into the user desktop, as opposed to just impersonating the user.
Bryan Roe committed
Sep 23, 2019 at 13:07 UTC
d55058e14f7ace63c9c4acad8c7deb88127e83eb
1 file changed
+9
-2
agents/meshcore.js
+9
-2
@@ -1645,8 +1645,15 @@ function createMeshCore(agent)
1645
try {
1646
switch (process.platform) {
1647
case 'win32':
1648
- //child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ["/c", "start", url], { type: childProcess.SpawnTypes.USER, uid: require('user-sessions').Current().Active[0].SessionId });
1649
- child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ["/c", "start", url], { type: childProcess.SpawnTypes.USER });
1648
+ var user = require('user-sessions').getUsername(require('user-sessions').consoleUid());
1649
+ child = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['cmd']);
1650
+ child.stderr.on('data', function () { });
1651
+ child.stdout.on('data', function () { });
1652
+ 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 + '"\r\n');
1653
+ child.stdin.write('SCHTASKS /RUN /TN MeshChatTask\r\n');
1654
+ child.stdin.write('SCHTASKS /DELETE /F /TN MeshChatTask\r\n');
1655
+ child.stdin.write('exit\r\n');
1656
+ child.waitExit();
1657
break;
1658
case 'linux':
1659
child = require('child_process').execFile('/usr/bin/xdg-open', ['xdg-open', url], { uid: require('user-sessions').consoleUid() });