pass parameter to a program through html link

瘦欲@ 提交于 2019-12-23 20:08:14

问题


I need to run a program from the local user's file system by clicking an html link.

When i use this

<a href="C:\Windows\System32\NETSTAT.EXE">CLICK</a>

It works fine. But When i try to pass a parameter to the exe file it fails.

<a href="C:\Windows\System32\NETSTAT.EXE -a">CLICK</a>

Anyone has an idea how is it possible to pass the parameter?

Thanks

UPDATE

The use of this is the following: An online system sends emails to users if a new record is available in the system. Therefore the users will click a link from their email client that will open their local exe program with the desired parameter, to show the new record.

I don't want to send emails with bat files since it is not allowed by my network admin.


回答1:


I see only one solution, use .BAT file, where will be "netstat.exe -a", named for example netstat-a.bat.

<a href="C:\Windows\System32\NETSTAT-A.BAT">CLICK</a>

It's quite impertect solution, but can works :)

You can also try this code, but it depend of browser and user rights:

<html>
 <head>
     <script language="JavaScript" type="text/javascript"> 
         MyObject = new ActiveXObject( "WScript.Shell" ) 
         function RunNotePad()  
         { 
            MyObject.Run("netstat.exe -a") ; 
        } 

    </script>
 </head>
 <body>
    <h1>Run a Program</h1>
    This script launch the file >> c:\windows\notepad.exe<p>
    <button onclick="RunNotePad()">Run Windows NotePad</button>
 </body>
</html> 



回答2:


As from my point of view as <A> is case sensitive it will treat C:\Windows\System32\NETSTAT.EXE -a as whole path rather than -a as an argument. Above link is working as it also take as an argument and it is there inside system32 that why it execute

Similarly it a treat <a href="C:\Windows\System32\NETSTAT.EXE -a">CLICK</a> as a whole file which is not there so there is only one method to solve the problem make it as .bat the whole path and save it and give the path in and save netstat-a.bat or whatever you want in <a> and give that whole path in <a>C:\Windows\System32\NETSTAT.EXE-a.bat</a>



来源:https://stackoverflow.com/questions/12210557/pass-parameter-to-a-program-through-html-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!