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
Solved

Run a .exe file from an ASP intranet page

Posted on 2010-11-18
9
839 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
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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 strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

860 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