Question

I am trying to launch some .exe files from the windows directory in HTML using activeX, here is the link http://msdn.microsoft.com/en-us/library/cc144191(VS.85).aspx

I know this might sound stupid or something, but I am going to open these HTML via C# web browser tool as it uses the IE engine.

It opens some of the .exe files from the link i provided up. for instance : C:\windows\system32\control.exe , but i try something more sensitive like c:\windows\system32\RecoveryDrive.exe , it simply does not works, i get an error.

Here is the HTML code I use. Thanks!

<body>
<p><h1>This is my web page</h1></p>
<button align="center" type=button onclick="ControlPanel();">Control Panel</button></p>
<button align="center" type=button onclick="RecoveryDrive();">MAGIC</button></p>
</body>
<script type="text/javascript" LANGUAGE="JavaScript">
    function ControlPanel()
    {
        var ws = new ActiveXObject("WScript.Shell");
        ws.Exec("c:\\windows\\system32\\control.exe");
    }
</script>
<script type="text/javascript" LANGUAGE="JavaScript">
    function RecoveryDrive()
    {
        var ws = new ActiveXObject("WScript.Shell");
        ws.Exec("c:\\windows\\system32\\RecoveryDrive.exe");
    }
</script>
Était-ce utile?

La solution

In order to execute applications that require elevated privileges, your application must do one of two things:

1: Run with elevated privileges. When you invoke a process, it will see that you are already using elevated privileges and run at the same level.

-or-

2: Create a launcher executable that requires elevated privileges. From the launcher, start the application that needs this privilege level. See this SO answer for more information about process privilege elevation.

HOWEVER

Doing this from a web browser complicates things as all web browsers are sandboxed to prevent malicious code from executing. You will have to put this web site in IE's Trusted Zone to even launch a non-privileged executable.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top