Skip to content

Commit 9a4560e

Browse files
author
Kasen IO
committed
Complete implementation for detached launching.
1 parent ba644fb commit 9a4560e

File tree

5 files changed

+49
-14
lines changed

5 files changed

+49
-14
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ yarn-error.log*
2121
*.sw?
2222

2323
# Batch files
24-
*.bat
24+
/*.bat
25+
26+
# PowerShell files
27+
/*.ps1
2528

2629
# Electron-builder output
2730
/dist_electron

bat/launcher.bat

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@echo off
2+
SETLOCAL ENABLEDELAYEDEXPANSION
3+
TITLE Vircadia Launcher - Detached Launching Utility
4+
set execPath="%~1"
5+
set parameters=%~2
6+
set parameters=!parameters:#20= !
7+
set parameters=!parameters:#40="!
8+
set parameters=!parameters:#60=^=!
9+
echo %execPath%
10+
echo %parameters%
11+
%execPath% %parameters%
12+
pause

src/App.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import * as Sentry from '@sentry/electron';
2727

2828
<v-bottom-navigation id="navBar">
2929
<v-btn-toggle dense tile borderless v-model="showTab">
30-
3130
<v-btn disabled value="Recent">
3231
<span>Recent</span>
3332
<v-icon>mdi-history</v-icon>
@@ -640,7 +639,7 @@ export default {
640639
"allowMultipleInstances": this.$store.state.allowMultipleInstances,
641640
"autoRestartInterface": this.$store.state.autoRestartInterface,
642641
"dontPromptForLogin": this.$store.state.dontPromptForLogin,
643-
"runAsChild": this.$store.state.runAsChild
642+
"launchAsChild": this.$store.state.launchAsChild
644643
});
645644
},
646645
openURL: function(url) {

src/background.js

+26-8
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ async function checkForInterfaceUpdates() {
394394
if (vircadiaMeta && vircadiaMeta.latest.version && interfacePackage && interfacePackage.package.version) {
395395
var cleanedLocalMeta = interfacePackage.package.version.replace(/_/g, '-');
396396
var versionCompare = compareVersions(vircadiaMeta.latest.version, cleanedLocalMeta);
397-
398-
console.info("Compare Versions: ", versionCompare);
397+
console.info('cleanedLocalMeta:', cleanedLocalMeta)
398+
console.info("Compare Versions:", versionCompare);
399399
if (versionCompare == 1) {
400400
return 1; // An update is available.
401401
} else {
@@ -611,7 +611,7 @@ ipcMain.on('launch-interface', async (event, arg) => {
611611
// TODO: Add "QUANTUM_K3_INSTAQUIT" environment variable.
612612

613613
console.info("Parameters:", parameters, "type:", Array.isArray(parameters));
614-
614+
console.info("arg.launchAsChild", arg.launchAsChild);
615615
if (arg.launchAsChild) {
616616
launchInterface(executablePath, parameters, arg.autoRestartInterface);
617617
} else {
@@ -633,17 +633,35 @@ function launchInterface(executablePath, parameters, autoRestartInterface) {
633633
}
634634

635635
function launchInterfaceDetached(executablePath, parameters) {
636+
// All arguments that have or may have spaces should be wrapped in ""
636637
win.webContents.send('launching-interface');
637638

639+
var pathToLaunch = process.cwd() + "\\bat\\launcher.bat";
640+
console.info("pathToLaunch:", pathToLaunch);
641+
642+
parameters = parameters.join(' '); // --arg1="" --arg2=""
643+
parameters = parameters.split(' ').join('#20'); // convert spaces to #20
644+
parameters = parameters.split('"').join('#40'); // convert " to #40
645+
parameters = parameters.split('=').join('#60'); // convert = to #60
646+
console.info("PARAMETERS:", parameters);
647+
executablePath = '"' + executablePath + '"';
648+
638649
var interface_exe = require('child_process').spawn;
650+
var launcherBat = interface_exe(pathToLaunch, [executablePath, parameters], {
651+
windowsVerbatimArguments: true
652+
});
653+
654+
launcherBat.stdout.on('data', function (data) {
655+
console.log('launcherBatOut: ' + data);
656+
});
639657

640-
var subprocess = interface_exe(executablePath, parameters, {
641-
windowsVerbatimArguments: true,
642-
detached: true,
643-
stdio: 'ignore'
658+
launcherBat.stderr.on('data', function (data) {
659+
console.log('launcherBatErr: ' + data);
644660
});
645661

646-
subprocess.unref();
662+
launcherBat.on('exit', function (code) {
663+
console.log('child process exited with code ' + code);
664+
});
647665
}
648666

649667
ipcMain.on('get-vircadia-location', async (event, arg) => {

vue.config.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ module.exports = {
3636
"deb"
3737
]
3838
},
39-
// "extraFiles": [
40-
// "settings.json"
41-
// ],
39+
"extraFiles": [
40+
{
41+
"from": "./bat/launcher.bat",
42+
"to": "./bat/launcher.bat"
43+
}
44+
],
4245
"appId": "com.vircadia.pantheon",
4346
"productName": "Vircadia Launcher",
4447
"copyright": "Vircadia"

0 commit comments

Comments
 (0)