Solved

Run a .exe file from an ASP intranet page

Posted on 2010-11-18
9
836 Views
Last Modified: 2012-05-10
Hi,
On my intranet ASP site, I would like the code required to run an .exe file located on the client side local drive (c:\Program Files) on a new window. Is there a way to do this bypassing the download/save alerts?
Thanks,
Robert
0
Comment
Question by:Roberth509
  • 5
  • 4
9 Comments
 
LVL 7

Expert Comment

by:Ironhoofs
Comment Utility
Because this is what any virus would love to do, a lot of functionality  to do this has been removed. However, if you register a protocol on the local computer  you can call its target directly from your HTML page.

To test this, first double click the myprog.reg file. This will register a protocol that points to notepad.exe. Then open myprog.html in your browser to check if it worked.




 myprog.html
myprog.reg
0
 

Author Comment

by:Roberth509
Comment Utility
The test worked fine...

a) What should I edit if say my .exe is in c:\Program Files\winamp\winamp.exe (just an example)?

b) Would I have to run myprog.reg on all computers?

Thanks
0
 
LVL 7

Expert Comment

by:Ironhoofs
Comment Utility
To run the program of your choice, change "notepad.exe" inside the myprog.reg file .Unfortunatly, you have to run this once for each workstation.

By installing the protocol a user essentially gives you permission to do the actions you defined. Therefore this is (in my opinion) a decent solution for intranet sites, but unrealistic for public websites.

0
 

Author Comment

by:Roberth509
Comment Utility
ok...one last point:  how do I deal with the spaces of my folder name (Arquivos de Programas) in your file. Do I simply replace them with 20%?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:Roberth509
Comment Utility
Sorry ...I meant %20...
0
 
LVL 7

Expert Comment

by:Ironhoofs
Comment Utility
To handle the problem of spaces in a file- or pathname, use the windows default and enclose the full path in quotation marks ("C:\Program Files\winamp\winamp.exe").

The reg file uses default C notation, therefore all special characters should be preceded by a "\".
The entry in the reg file would therefor look like:

[HKEY_CLASSES_ROOT\MYPROG\shell\open\command]
@="\"C:\\Program Files\\winamp\\winamp.exe\""

0
 
LVL 7

Expert Comment

by:Ironhoofs
Comment Utility
One more tip: its possible to pass parameters to the protocol. Unfortunatly, i could only get that to work with a additional program.

To add a parameter you would change the  regfile to:

[HKEY_CLASSES_ROOT\MYPROG\shell\open\command]
@="\"C:\\Program Files\\winamp\\winamp.exe\" %1"

And you would change the HTML file to:

<a href="MYPROG:c:\mymusiclib\nicemusic.mp3"> Play some nice music</a>

The problem is that the value of the parameter includes the protocol name. The result of clicking the link is that winamp.exe is called with "MYPROG:c:\mymusiclib\nicemusic.mp3" as parameter and will not be able to find that file.

I used a workaround by pointing the regfile to my own program, stripping the parameter and launching the final program with the correct data. This way you can allso add some security by encrypting/decrypting the passed data.
0
 

Accepted Solution

by:
Roberth509 earned 0 total points
Comment Utility
This is the solution I ended up using...it also works for .exe files:

<script type="text/javascript">
var saprisco = 'file://C:/Projetos Primavera/saprisco.xls'.replace(/ /g,' ');

function Run(commandtoRun, commandParms) {
  var oShell = new ActiveXObject("Shell.Application");
  oShell.ShellExecute(commandtoRun, commandParms, "", "open", "1");
  return false;
}
</script>
<a href="#" onclick="return Run('excel.exe',saprisco)">Click here</a>
0
 

Author Closing Comment

by:Roberth509
Comment Utility
IMy solution does not involve having to set up any machine beforhand...
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now