Forum Stats

  • 3,757,881 Users
  • 2,251,286 Discussions
  • 7,869,962 Comments

Discussions

Bookmark Calling Remote Js File

George_samaan
George_samaan Member Posts: 17 Blue Ribbon
edited Jun 24, 2016 7:32AM in JavaScript - Nashorn

Dears

I have created the following bookmark in IE 11:

javascript:(

function george() 

{

var script = document.createElement('script');

script.type='text/javascript';

script.onload = function() {georgeee()};

script.src = 'http://mycompany/measurement.js'+ 

Math.floor((new Date).getTime()/3600000000);;

document.body.appendChild(script);

}

)();

measurement.js contain the following:

javascript:(function georgeee()

{

var oShell = new ActiveXObject("WScript.Shell");

var oExec = oShell.Exec

(

'powershell.exe -Command " & { $port= new-Object System.IO.Ports.SerialPort COM1,9600,None,8,one ; $port.open() ; $port.ReadLine() ; $port.Close() ; [Environment]::Exit(1) } "'

);

Output = oExec.StdOut.ReadAll(); 

var substroutput = Output.substr(8,5);

document.getElementById('measureSrcContainer&# 39;).value = substroutput;

})();

But it is not working though putting the code of measurement.js directly in the bookmark it is working.

Answers