Connecting Tech Pros Worldwide Forums | Help | Site Map

Dos commands

Member
 
Join Date: Nov 2007
Posts: 56
#1: Nov 20 '08
Hi guys,

It's me again :-)

In Javascript it's perfectly possible to run a file using the Shell.

But is it also possible to perform multiple tasks but not at the same time?

So like opening the command and then send a second command that puts the good old Hello World in it. Just to make the test.

Expand|Select|Wrap|Line Numbers
  1. var shell=new ActiveXObject("WScript.Shell");
  2.  
  3. function openconnection()
  4. {
  5. shell.Run("cmd /K", 1);
  6. }
  7.  
  8. function command()
  9. {
  10. shell.Echo("Hello World");
  11. }
  12.  
This was something I tried but I get the error that it can't get the file

gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,134
#2: Nov 20 '08

re: Dos commands


just a note: fortunatly that is not! possible in JavaScript, it is microsofts JScript and uses ActiveX and relies on a MS-OS at all because of the WSH-usage ... you may only use this with IE and Windows and thats one of the reasons why IE is simply bad! a webapp shouldn't have such privileges because unaware users could be easyly harmed with such possibilities ...

just my 2 cents ... ;)

kind regards
Member
 
Join Date: Nov 2007
Posts: 56
#3: Nov 21 '08

re: Dos commands


Although I agree with you to a certain extent, I do feel that it could be useful.

Ofcourse there will always be a risk of people using malicious webapps to do harm to one's pc, but in this case I'm the only user.

Besides the whole security issue is useless. Or you offer the ability to work with Dos-commands or you don't. But trying to limit it by just authorizing a few commands to be executed isn't going to work.

If I can't put "format c:" in the function then I can put it in a .bat file and call for the .bat-file. Stays absolutely the same. So trying to limit is just plain stupid.
My two cents. Thus making 4 cents already ;-)

But in other words, it's not possible which was my question. Thanks for the reply!
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,134
#4: Nov 21 '08

re: Dos commands


i didn't say that something is not possible ... i just said that it is not JavaScript ... it is just MS's use of the WSH and so everything that you might do with that is possible ... and even when it is not with the WSH you just need to write an ActiveX control that could easyly run outside any sandbox of the browser. so just to give a browser the ability to execute something like that is a potential security risk and saying that this is not a problem since only one person uses it is no intelligent argument, because the ability of using that in a harmful way is just given and doesn't make sense for a webbrowser or an application that runs in it ... in case you do an app for your own you could format your drive at your own command-line or use correct admin-tools to do that remote ... but a webapp should never do that and should never has the possibility to do that ... it is a simple idea of trust ... that could be just destroyed by offering such abilities ... and even worse by apps that uses them ...

ActiveX, WSH, IE have and are serious problems in this regard ...
Reply


Similar JavaScript / Ajax / DHTML bytes