Telnet Using Applets in JavaScript

I am trying to open a telnet window and send some keys to this active window. The following is the JavaScript code:

var oWshShell = new ActiveXObject("WScript.Shell"); oWshShell.Run("telnet 43.43.22.45 23"); //oWshShell.Run("firefox.exe http://www.google.com"); //oWshShell.Run(" notepad.exe"); oWshShell = null; 

But I can’t open them. He says the file does not exist. However, commented lines work fine when they are without comment. What could be the problem?

Thanks in advance.

+6
source share
3 answers

@Avi, I don’t think you can execute this type of command when the page loads, unless you use Internet Explorer and enable full trust protection. However, if you must do this, you simply need to specify the full path to telnet.exe . Just beware that Windows uses \ to separate directory levels, but it is a special character for javascript and it must be escaped; i.e:

 var path = "c:\\Windows\\System32"; // this is c:\Windows\System32 in javascript 
+1
source

Instead, you tried to use a url like telnet://43.43.22.45 ?

 <a href="telnet://43.43.22.45">Connect to server</a>. 
0
source
 oWshShell.Run("telnet 43.43.22.45 23"); 

Telnet is on the system default path. So that should work.

 //oWshShell.Run("firefox.exe http://www.google.com"); 

Firefox is not in the system path. Therefore, running does not know how to find it.

 //oWshShell.Run(" notepad.exe"); 

Note the space before the “notebook” → This file name does not exist.

0
source

Source: https://habr.com/ru/post/914629/


All Articles