javascriptnode.jsspawnlnk

Spawning a .lnk windows shortcut with node.js gives "UNKNOWN" error


I'm having a game spawned as a child process. It all works nice and well with the game's original .exe file. However, I'd like it to execute minimized, and the only way to do it as far as I can tell is to create a windows shortcut (.lnk file, in the same directory) and set the launch options to minimized. Node.js doesn't like that:

    internal/child_process.js:313
    throw errnoException(err, 'spawn');
    ^

Error: spawn UNKNOWN
    at exports._errnoException (util.js:1026:11)
    at ChildProcess.spawn (internal/child_process.js:313:11)
    at exports.spawn (child_process.js:380:9)
    at ExecDom4Server (D:\Google Drive\Clockwork Hounds stuff\MrClockworkBot\v10
\MrClockworkBot.js:568:42)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

The game itself has a few specific arguments on graphic settings but none to launch it minimized either. Here's the particular code:

function execDom4Server(name, args)
{
    var spawn = require('child_process').spawn;
    childrenProcesses[name.toLowerCase()] = spawn(dom4root + "dom4.exe.lnk", args);
    updateDom4Games();
}

I've looked everywhere for this, but I suppose it's fairly specific. I don't know if it's just node.js being unable to handle .lnk files. Any pointers that you can give me would be greatly appreciated!


Solution

  • This should work if you use the shell option of spawn()

    spawn('application.lnk', args, { shell: true })