Solved

Run a .exe file from an ASP intranet page

Posted on 2010-11-18
9
840 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
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 modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

756 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