This is a mirror of official site: http://jasper-net.blogspot.com/

How to execute a Local File using Html Application?

| Tuesday, October 5, 2010
Did you ever want to run an application from your local resource inside your HTML page? If so, you will face some issues. It will never run any application from local resource directly. It may ask you to download the file before running it. This is due to browser security issue as the code runs inside the browser sandbox.

So, what to do for this? In this post, I will describe you the steps resolve to do this. Read the complete post in order to learn the same.

As I mentioned above, you can’t run application from browser window due to security reasons. To execute file you need to use .HTA applications (which is a HTML Application). HTA applications run outside the browser window just like a normal application and have full trust support.

If you are new to Html Application, read more about it here: http://msdn.microsoft.com/en-us/library/ms536471(v=VS.85).aspx

<script type="text/javascript" language="javascript">
   function RunFile() {
   WshShell = new ActiveXObject("WScript.Shell");
   WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
   }
</script>

Here you can see that, first I am creating the instance of the “WScript.Shell” ActiveXObject and then calling the Run() method of the newly created object with proper parameters.

Read more: Kunal's Blog

Posted via email from .NET Info

0 comments: