How do I perform a shell execute in a chrome extension?
Asked Answered
B

3

18

I'm not finding a way to do this in the chrome.* API or even the experimental. It doesn't run through wscript so ActiveXObject("Shell.Application") isn't allowed.

I fear that my only option is to build a dll with NPAPI but I wanted to see if there was a simpler way.

Bueno answered 12/9, 2010 at 15:52 Comment(4)
If you actually managed to succeed, in what sense would Chrome be sandboxed anymore?Impropriate
@Kirk, well, you can use NPAPI plugins within extensions to go outside the sandbox.Mckim
@Mohamed, Yikes, that's interesting. Does Chrome provide any special warning when an extension is being installed with such excess privileges?Impropriate
@Kirk, well it goes to an approval process first which might take some time. Perfoming shell operations is a risky operation :) And only NPAPI can do risky stuff.Mckim
M
8

If you want to do anything Natively, you need to use NPAPI. That allows you to run code outside the sandbox for your extensions.

http://code.google.com/chrome/extensions/npapi.html

Mckim answered 12/9, 2010 at 16:9 Comment(3)
Looks like my only tool is a "hammer". Bummer, but it might do the job. thanks.Bueno
There must be some NPAPI plugins out there already :) Try looking at this: goo.gl/SzUpMckim
Also, Chrome ended support for NPAPI.Venuti
P
15

To update this for a fellow wary lonesome traveler, even NPAPI is deprecated and being phased out. One of the alternatives mentioned in the NPAPI deprecation blog post that looks suitable for this type of problem (and pretty nifty really) is the Native Messaging API.

Percival answered 4/6, 2014 at 5:3 Comment(2)
Important caveat of this approach: unlike NPAPI plugins, Native Messaging hosts cannot be bundled with the extension in Chrome Web Store.Thereunder
The current link to the Native Messaging API doc is: developer.chrome.com/extensions/nativeMessagingBianca
M
8

If you want to do anything Natively, you need to use NPAPI. That allows you to run code outside the sandbox for your extensions.

http://code.google.com/chrome/extensions/npapi.html

Mckim answered 12/9, 2010 at 16:9 Comment(3)
Looks like my only tool is a "hammer". Bummer, but it might do the job. thanks.Bueno
There must be some NPAPI plugins out there already :) Try looking at this: goo.gl/SzUpMckim
Also, Chrome ended support for NPAPI.Venuti
E
7

Alternatively, you might want to have two applications:

  1. a "client" that works within a chrome extension and
  2. a "local server" where the actual command is executed.

Whenever the extension needs to execute a command, it can connect to the local server via tcp connection.

Elenor answered 9/11, 2018 at 22:56 Comment(1)
@penduDev, unfortunately, I don't have any code to share -- just the abstract idea.Elenor

© 2022 - 2024 — McMap. All rights reserved.