How to run WinMerge to comapre 2 files when triggering from a hyperlink click?

Try the below scripts. Note that the web browser must allow Javascript and ActiveX to run.

<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>

Another version with input argument for the function call:

<html>
    <head>
        <script type="text/javascript">
        function runProgram(fileLeft, fileRight)
        {
            var shell = new ActiveXObject("WScript.Shell");
            var appWinMerge = "\"C:\\Program Files\\WinMerge\\WinMergeU.exe\" /e /s /u /wl /wr /maximize";
            shell.Run(
				appWinMerge
				+ " " +"\""+fileLeft +"\""
				+ " " +"\""+fileRight +"\""
			);
        }
        </script>
    </head>
    <body>
        <a href="javascript:runProgram('Path\\to\\your\\file', 'Path\\to\\your\\file2');">Run program</a>
    </body>
</html>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: