java调用服务器端exe文件和客户端exe文件

1.调用服务器端文件,以下只显示类文件代码:

@RequestMapping(params = "method=openExe")
public void openExe(HttpServletResponse response){
 Runtime rn = Runtime.getRuntime();
 Process p = null;
 try {
 p = rn.exec("\"D:/Program Files/Tencent/QQ/Bin/QQ.exe\"");
 
//取得命令结果的输出流
 InputStream fis=p.getInputStream(); 
//用一个读输出流类去读  
 InputStreamReader isr=new InputStreamReader(fis);   
//用缓冲器读行      
             BufferedReader br=new BufferedReader(isr);      
             String line=null;      
            //直到读完为止      
            while((line=br.readLine())!=null)      
             {      
                 System.out.println(line);      
             } 
            isr.close();
            br.close();
 }  catch (IOException e)      
        {      
            e.printStackTrace();      
        }


}


2.调用客户端文件:

新建.reg注册表文件,内容如下,如见sims.reg:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SIMS]
@="SIMS"
"URL Protocol"="D:\\Program Files\\Tencent\\QQ\\Bin\\QQ.exe %l"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SIMS\DefaultIcon]
@="%SystemRoot%\\system32\\url.dll,0"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SIMS\Shell]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SIMS\Shell\open]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SIMS\Shell\open\command]
@="D:\\Program Files\\Tencent\\QQ\\Bin\\QQ.exe %l"

双击文件写入注册表,在浏览器输入sims://即可访问exe文件,在jsp页面调用只需js方法location.href到sims://即可。


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值