Solved

Run a .exe file from an ASP intranet page

Posted on 2010-11-18
9
841 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 7

Expert Comment

by:Ironhoofs
ID: 34162821
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
ID: 34162931
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
ID: 34164397
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Roberth509
ID: 34166070
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
 

Author Comment

by:Roberth509
ID: 34166077
Sorry ...I meant %20...
0
 
LVL 7

Expert Comment

by:Ironhoofs
ID: 34171460
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
ID: 34171523
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
ID: 34202331
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
ID: 34224743
IMy solution does not involve having to set up any machine beforhand...
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP sending two datas 2 28
Asp response.write to clients 6 45
Permission on folders 6 32
Add Log to powershell Script 14 25
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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 count occurrences of each item in an array.

739 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