I'm generating an HTML report by C# to print pairs of files in a table which has 3 columns: the first two columns used for the filenames and the 3rd column is a hyperlink Compare - I want this link to run WinMerge to compare to two files and I currently don't know how to do it.
Try this
<html>
<head>
<script type="text/javascript">
function runProgram()
{
var shell = new ActiveXObject("WScript.Shell");
var appWinMerge = "\"C:\\Program Files\\WinMerge\\WinMergeU.exe\" /e /s /u /wl /wr /maximize";
var fileLeft = "\"D:\\Path\\to\\your\\file\"";
var fileRight= "\"D:\\Path\\to\\your\\file2\"";
shell.Run(appWinMerge + " " + fileLeft + " " + fileRight);
}
</script>
</head>
<body>
<a href="javascript:runProgram()">Run program</a>
</body>
</html>
Sorry this answer sucks, but you can't launch an just any external application via a click, as this would be a serious security issue, this functionality isn't available in HTML or javascript. Think of just launching cmd.exe
with args...you want to launch WinMerge with arguments, but you can see the security problems introduced by allowing this for anything.
The only possibly viable exception I can think of would be a protocol handler (since these are explicitly defined handlers), like winmerge://
, though the best way to pass 2 file parameters I'm not sure of, if it's an option it's worth looking into, but I'm not sure what you are or are not allowed to do to the client, so this may be a non-starter solution.
The reasonable way how to launch apps from HTML is through url schemes. So you can launch email via mailto:
links and irc through irc:
links. Individual apps can implement these schemes, but I'm not sure WinMerge does this.
Make a batch file and call the bacth file in Window.open. Here how it works
- make a file in notepad
- write your script : start wmplayer "\dotnet\sc\1234.mp4" /fullscreen
- save as : test.bat in \dotnet\sc\test.bat
in html
window.open('file://dotnet/sc/test.bat')
Enjoy..
I've wrote a small extension to do so.
Since you are creating the page using C# you may want to implement this:
https://github.com/felix-d-git/DesktopAppLink
Basically u are creating some registry entries to parse the links you click in your html page.
The browser will then ask to open the specified app.
C#:
DesktopAppLink.CreateLink("applink.sample", "\"<path to exe>\"", "");
HTML:
<a href="applink.sample:">Run Desktop App</a>
Result:
© 2022 - 2024 — McMap. All rights reserved.