471,887 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

running command prompt from javascript

Uncle Dickie
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:

Expand|Select|Wrap|Line Numbers
  1. function myTry(){
  2.     oShell = new ActiveXObject("wscript.shell");
  3.     oShell.run("cmd /K nbtstat -R");
  4. }
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.
Apr 8 '09 #1
4 3365
5,390 Expert Mod 4TB
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
Apr 8 '09 #2
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.
Apr 8 '09 #3
2,476 2GB
This is not the question "ActiveXObject" only.
So many security concerns are dere ;)
Apr 8 '09 #4
5,390 Expert Mod 4TB
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
Apr 8 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Xarky | last post: by
5 posts views Thread by vj | last post: by
1 post views Thread by TPhung | last post: by
6 posts views Thread by mjahabarsadiq | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.