sindresorhus/opn

Do you want to work on this issue?

You can request for a bounty in order to promote it!

How do you close a program once you've opened it? #152

doverradio posted onGitHub

Hello, I was able to successfully open up a program using your library in Windows 10. Here is the code:

const open = require('open');

// Opens the program WordPerfect in the default image viewer
(async () => {
    await open('C:\\Program Files (x86)\\Corel\\WordPerfect Office X4\\Programs\\wpwin14.exe', {wait: true});
    console.log('Did WordPerfect open?');

})();

However, it's not clear how to close this once I've completed the tasks I need within that opened program.

How do I close this after I've completed using the opened program?


open give you a sub process, you can call it to kill itself. Unfortunately, that sub process create another process, which should be killed.

@sindresorhus Do you think that it is possible to resolve with sub process of start command(on window)?

posted by Hongarc over 5 years ago

@Hongarc can you give an example?

posted by ryanesch about 5 years ago

The main process create a new process (A)

A process creates another process(B, the application you want here)

You can close A process but I don't know how to close B process (you can add argument for B process but to get it)

posted by Hongarc about 5 years ago

Any ideas? Facing the same issue here

posted by einarpersson about 5 years ago

also curious about this. I would love to open a chrome tab and then close it when my program (static file server) exits.

posted by wgottschalk about 5 years ago

Is there any solution? Got stuck here too!

posted by ZzqiZQute almost 5 years ago

Yeap, same problem here!

EDIT: So I tried calling kill on the item it returns, via tree-kill, but still doesn't work

posted by Lunchb0ne almost 5 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests