I have a web app that uses the old MS remote desktop ActiveX object to connect to one of our servers.
Originally, the code was in VBScript, as that was the sample given on the MS site. However, MS has dropped support for VBScript in IE 11, so I'm trying to change it to work with Javascript. Operationally, it's working for the most part. I can connect to the server. However, the view of the server is appearing as a small square in the middle of the page. The height and width of the control are being set, and it appears they are correct, as I can see the control's outline on the page at the size I want it. But the view itself is very small (this doesn't happen in the VBScript version of the page). In addition, the "disconnected" event doesn't seem to fire now that I've converted the code to javascript. Has anyone ever been able to get this component working using Javascript? Are there any alternatives out there that don't require any installation on the server or the client?
Okay, a little update for anyone else who might have this happen, AND another problem. I finally got this all working with the following HTML and JS:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="./scripts/jquery-1.10.2.js" ></script>
</head>
<body>
<script type="text/javascript" for="rdpClient" event="OnDisconnected(reason)">
OnDisconnected(reason);
</script>
<script type="text/javascript">
var pw;
function GetPassword() {
return $.ajax({
url: "OpenNewRDP.aspx/GetPassword",
type: "POST",
contentType: "application/json;charset=utf-8",
dataType: "json",
data: ''
});
}
GetPassword().done(function (data) {
pw = data.d;
var rdpClient = document.getElementById("rdpClient");
rdpClient.AdvancedSettings2.ClearTextPassword = pw;
});
function OnReadyStateChange() {
var rdpClient = document.getElementById("rdpClient");
if (rdpClient != undefined) {
if ((rdpClient.readyState == 4) && (rdpClient.SecuredSettingsEnabled)) {
SetRdpDefaultSettings();
} else {
rdpClient.Server = "";
alert("Trusted Sites Error");
}
}
}
function SetRdpDefaultSettings() {
var rdpClient = document.getElementById("rdpClient");
var resHeight = screen.height;
var resWidth = screen.width;
rdpClient.DesktopHeight = resHeight - 100;
rdpClient.DesktopWidth = resWidth - 30;
rdpClient.height = resHeight - 100;
rdpClient.width = resWidth - 30;
rdpClient.UserName = "<%=UserName%>";
//rdpClient.AdvancedSettings2.ClearTextPassword = pw;
if (rdpClient.SecuredSettingsEnabled) {
rdpClient.SecuredSettings.StartProgram = "<%=StartProgram%>";
rdpClient.SecuredSettings.WorkDir = "c:\\";
} else {
alert("Trusted Sites settings need to be updated.");
}
}
function OnDisconnected(disconnectCode) {
window.close();
}
</script>
<object
id='rdpClient'
onreadystatechange="OnReadyStateChange()"
codeBase='/wpresources/downloads/msrdp.cab#version=5.2.3790.0'
classid='CLSID:7584c670-2274-4efb-b00b-d6aaba6d3850'
VIEWASTEXT>
<PARAM NAME='Server' VALUE='<%=ServerName%>'>
<PARAM NAME='StartConnected' VALUE='1'>
</object>
</body>
</html>
HOWEVER, I wanted to make sure this still worked in older versions of IE as well, since we have a bunch of clients that for one reason or another are still using IE 7 or 8 and just can't/won't upgrade. So I put the following line in the header to simulate older versions:
<meta http-equiv="X-UA-Compatible" content="IE=7"/>
and I discovered that it doesn't work in IE 7 or 8 (but works fine in 9, 10, and 11). When running in IE 7 or 8, I get an "unknown exception" in this routine (on the line indicated):
GetPassword().done(function (data) {
pw = data.d;
var rdpClient = document.getElementById("rdpClient");
rdpClient.AdvancedSettings2.ClearTextPassword = pw; **// error occurs here**
});
Any clue why IE 7 and 8 choke on this?