开发者

Are there any web browser plugins that can give access to machine's command line? (for local use)

开发者 https://www.devze.com 2023-01-11 00:21 出处:网络
EDIT: please read the question and why I want to do it before passing judgement on this, I want to develop locally using a web browser as the interface, I KNOW its a security hole, but if there is a w

EDIT: please read the question and why I want to do it before passing judgement on this, I want to develop locally using a web browser as the interface, I KNOW its a security hole, but if there is a way for the end user to disable this security so it can be used locally I want to know, of course this isn't possible under normal circumstances as this would create a security issue

Question: I want to make some apps that run locally and just use jquery as the user interface so it would have to have access to the machine's command line, at the least, so that it can make calls to the system, I don't want to do it through a web server, in this case, as this overcomplicates it as far as permissions, etc, I want the jquery app to run more like a native app so that it can open files for the user to display to them, etc..

I am wondering if anyone knows of plugin开发者_Python百科s, such as for firefox, that allow this to happen so that I could install this on my machine to make an app like this.. thanks for any info


In general, browsers go to great lengths to make that impossible, because they present an immense security hole. (Consider, eg, a web page that could launch rm -rf /.)


I don't know if you can access command line, but you can read local filesystem.

This function do this (in firefox)

function readFile(arq) {
      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
      var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
      file.initWithPath(arq);

      // open an input stream from file  
      var istream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
      istream.init(file, 0x01, 0444, 0);
      istream.QueryInterface(Components.interfaces.nsILineInputStream);

      var line = {}, lines = [], hasmore;  
      do {  
        hasmore = istream.readLine(line);  
        lines.push(line.value);   
      } while(hasmore);  
      istream.close();  
      return lines;
    }


In the browser, without a web server you could probably use VBScript (only in IE of course) to do what you're looking for - so you could potentially do "data access" type stuff in VBScript and your UI components and stuff in JQuery - I think that would be a mess though. The only other thing I can think of would require you to install a light http server on the client machines... and you could probably write an ajax wrapper to interact with the command line on the "local" web server.... I know that's not exactly what you're going for, but as far as I know I don't think you options.


This is something I did a long time back. I used to have a webpage(local html) displayed on my desktop as a background. I had used that to launch programs on my PC. The way I did that was using :

  • VBScripts
  • .bat files
  • I just tried, it only works with IE(checked IE 6/7). When you call a .bat or .vbs file as a file -- file:///c:\ or using local host. It will give you an option to run the file.

    VBScript Example to get your feet wet.


    It's been 10+ years since I've even looked at this, but HTAs might be what you're looking for.


    Try one of the following:

    On Windows, you can make an HTA, which is a web page running in IE, but with Windows Script Host access levels (you can do anything).

    On a Mac, you can build an html+javascript application with Dashcode.

    Elseware (and on Mac and Windows), you can build an html+javascript application in Adobe Air.

    0

    精彩评论

    暂无评论...
    验证码 换一张
    取 消