Forum Moderators: open

Message Too Old, No Replies

Trap Window.close event

Run a dos command

         

aspdaddy

10:48 am on Jan 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,
Can anyone help me with this dilema. I have an Extranet app which users connect to using a VPN.

When users close the broswer I want to run the following dos command: rasdial myVPN /disconnect

I have found the window.close event documented in the dhtml ref but cant figure out how to use it as an event handler to run some code.

Thanks.

DrDoc

6:24 pm on Jan 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tricky ... It can't be done directly using JavaScript. What you would need to do is open a new page (using window.open) which loads a PHP/Perl/ASP file which runs said DOS command. Upon running the command, the file prints a JavaScript self.close() to the screen to close that window.

leniz

1:51 am on Jan 11, 2006 (gmt 0)



I think ,if you can do that ,others can also
run " format c:"

Just I think so.

aspdaddy

6:44 pm on Jan 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorted it. As long as the logoff window is created with javascript this works nicely:


<script language=JavaScript>
function logoff ()
{
var shell = new ActiveXObject("WScript.Shell");
shell.run ("cmd.exe rasdial myVPN /disconnect");
window.close();
}
</script>
<body onload="return logoff();"></body>

leniz, It can be done safely using custom IE security levels and trusted sites. A tip - never connect to the web using an account that has permission to format c. Most exploits run under the logged on users account.

DrDoc

10:52 pm on Jan 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is that IE itself can have more rights than the logged in user ... which is quite frequently exploited.