17

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.

wtjones
  • 4,090
  • 4
  • 34
  • 41
  • If you actually managed to succeed, in what sense would Chrome be sandboxed anymore? – Kirk Woll Sep 12 '10 at 16:01
  • 1
    @Kirk, well, you can use NPAPI plugins within extensions to go outside the sandbox. – Mohamed Mansour Sep 12 '10 at 16:10
  • 1
    @Mohamed, Yikes, that's interesting. Does Chrome provide any special warning when an extension is being installed with such excess privileges? – Kirk Woll Sep 12 '10 at 16:50
  • 2
    @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. – Mohamed Mansour Sep 12 '10 at 18:15

3 Answers3

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.

mgalgs
  • 15,671
  • 11
  • 61
  • 74
  • 2
    Important caveat of this approach: unlike NPAPI plugins, Native Messaging hosts cannot be bundled with the extension in Chrome Web Store. – Xan Jun 04 '14 at 06:32
  • 1
    The current link to the Native Messaging API doc is: https://developer.chrome.com/extensions/nativeMessaging – Adrian Günter Jun 23 '15 at 20:42
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

Mohamed Mansour
  • 39,445
  • 10
  • 116
  • 90
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.

John Henry
  • 2,419
  • 2
  • 20
  • 22