E
E
Edward Treit2020-01-02 20:25:40
Node.js
Edward Treit, 2020-01-02 20:25:40

Why won't the game's exe file launch?

Good day. I'm trying to write a launcher for an Electron game. Here is the code:

const child = exec('C:/Games/папка игры/что-то там.lnk', callback);

And it works, the game starts, everything is fine. But if I try instead of a shortcut (.lnk) to run through an executable (.exe):
const child = exec('C:/Games/папка игры/что-то там.exe', callback)
, then the game tries to start, but after a couple of seconds the window closes. Exit event listener on child after exit writes
child process exited with code 3221225477 and signal null

The following is in the error
Error: Command failed: C:\Games\папка игры\что-то там.exe

    at ChildProcess.exithandler (child_process.js:308)
    at ChildProcess.emit (events.js:203)
    at maybeClose (internal/child_process.js:1021)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283)
and that's it, nothing else interesting. execFile, spawn instead of exec don't work. It's just that programs (excel, calc, cmd) are launched via exe and work, but games do not.
Win 10 system. Node 12.14.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2020-01-03
@EdMSL

the problem is in the cwd parameter (working directory)
https://nodejs.org/dist/latest-v12.x/docs/api/chil...
by default as the folder containing the specified .exe
In node, by default, this parameter is taken from process.cwd()
https://nodejs.org/dist/latest-v12.x/docs/api/proc...
which corresponds to the working directory of your process node

I don't fully understand what it is for
it specifies the "working directory of the process", all relative paths used in the program being run will be calculated relative to this directory

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question