running command prompt from javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Uncle Dickie
    New Member
    • Nov 2008
    • 67

    running command prompt from javascript

    Hi All,

    I have a requirement (that to be perfectly honest I don't fully understand) to run "nbtstat - R" from a webpage. To quote from Microsoft: The nbtstat-R command purges the name cache and reloads all #PRE entries from the LMHOSTS file. #PRE entries are the LMHOSTS name entries that are preloaded into the cache.

    To give a little more information this is for an embedded webserver product we make and from what I understand once we have programmed the MAC address the nbtstat-R needs to be run to register the changes. Possibly!!.

    Anyway, I have a way of doing this in Internet Explorer:

    Code:
    function myTry(){
    	oShell = new ActiveXObject("wscript.shell");
    	oShell.run("cmd /K nbtstat -R");
    }
    But I would really like the code to be cross browser compatible (if it is not possible I guess I will end up with a text section telling the user how to do it).

    If anyone has any ideas of how I can achieve the above it would be much appreciated.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    it is not really possible to do that reliably in a cross-browser way ... for every browser and may be for every browser-version you would need to implement a specific solution, because it is definitly unsafe to let a webapp call such things at the client ... and a browser will not allow that ... and to let the browser do such things you would need to get privileges, that the user has to agree with, and you need to program against the specific browser-api to get such calls to work. i don't want to say that it is impossible but it has a lot of things that you cannot really control, because the user always has to agree with those actions.

    kind regards

    Comment

    • Uncle Dickie
      New Member
      • Nov 2008
      • 67

      #3
      That is pretty much what I feared so I'll just go for the disable button option with suitable text if ActiveX is not available.

      Thanks for the input.

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        This is not the question "ActiveXObj ect" only.
        So many security concerns are dere ;)

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          ahh ... wait ... is the 'embedded' webserver on the client too? then you could of course do it 'serverside' ... which would be much more painless ;)

          kind regards

          Comment

          Working...