Spawn fails when calling a Windows lnk/shortcut file

9 views
Skip to first unread message

John Peat

unread,
Jun 10, 2013, 7:10:17 AM6/10/13
to node-...@googlegroups.com
I'm not sure if this is a NW, node.js or 'my being stupid' issue, but I'd assumed that as well as .exe files, I could probably use node's child_process spawn to execute a lnk/shortcut file.

It fails, however, with

Error: spawn Unknown system errno 193
at errnoException (child_process.js:975:11)
at Process.ChildProcess._handle.onexit (child_process.js:766:34)

Any ideas where I should start looking - is this just a silly request!? :)

Using 0.5.1 on Windows 7-64

Michael Winser

unread,
Jun 12, 2013, 9:11:29 PM6/12/13
to node-...@googlegroups.com
John,

You might consider using 


gui.Shell.openItem('test.txt');

Instead of "test.txt" you could pass the path to the shortcut.

I'm pretty sure that on Windows spawn ultimately resolves to CreateProcess and Shell.openItem resolves to ShellExecute.  The latter closely represents what happens when you double click on a file in Windows.

There is a COM service for resolving shortcuts to targets and one could imagine a helper that creates the process, passes the arguments and so on.  In practice this is almost impossible to do for all possible shortcuts.  ShellExecute (via gui.Shell.openItem) is really the only way to go.

Caveat: the above is from my knowledge of Windows programming more than any knowledge of node-webkit internals.

I hope this helps,

Michael 


--
You received this message because you are subscribed to the Google Groups "node-webkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-webkit...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

John Peat

unread,
Jun 13, 2013, 11:20:13 AM6/13/13
to node-...@googlegroups.com
You're absolutely right that gui,Shell.openItem is better for my purposes - as it accepts .exe, .lnk and even http:// and mailto:// and other redirects quite happily.

I'm guessing that spawn/exec is really more for subtasks you want to monitor the output of - I have no need for that here, I'm just launching stuff.

Thanks

JP

John Peat

unread,
Jun 14, 2013, 10:55:58 AM6/14/13
to node-...@googlegroups.com
p.s. I assume there's no way to get even a return code from an openitem call either??

Michael Winser

unread,
Jun 14, 2013, 11:42:24 AM6/14/13
to node-...@googlegroups.com
Indeed, there is no way.  There's no guarantee that your openitem call will actually result in a discrete process that starts, runs and exits.  If you open a .doc file then it will ensure that the Word app is running and then send it a message to open the doc.

As I mentioned before, you're basically asking the shell to open the document the same way the user would by double clicking on it.

Michael
Reply all
Reply to author
Forward
0 new messages