0

我在用着:

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String Ip = request.getRemoteAddr();
    System.out.println("IP " + Ip);
    processRequest(request, response);
}

public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    String name = request.getParameter("name");
    out.println("<h3>You have entered name : "+name+"<br>");
    out.println("<b><font color='blue'>IP Address of request : </font></b>" + request.getRemoteAddr() + "</h3>");
    System.out.println("<h3>You have entered name : " + name + "<br>");
    System.out.println("<b><font color='blue'>IP Address of request : </font></b>" + request.getRemoteAddr() + "</h3>");
}

..它返回用户IP地址,我需要将其存储为变量并在以下位置使用该变量:

public void setRc(String rc) throws IOException { //need to start/call doGet() and/or processRequest() here....
    try {
        Process d = Runtime.getRuntime().exec("c:\\commands\\psexec \\\\" + Ip + " -i -s -d \"C:\\Program Files (x86)\\Microsoft Configuration Manager Console\\AdminUI\\bin\\i386\\rc.exe\" 1 " + rc);
    } catch (Exception e) {
        System.out.println("FROM CATCH " + e.toString());
        this.rc = rc;
    }
}

这是用于我们 IT 组的 Web 应用程序 - 在用户端打开远程连接 gui - 它将目标 pc 作为 rc 之后的变量。

因此,命令将是: psexec - 在 Web 应用程序用户桌面上,带有参数 xyz 并在目标 PC 上运行 rc.exe...

它的工作方式:用户输入与 1.)user、2.)pc 或 3.) ID# 有关的信息(到 Web 应用程序) - 然后他们单击提交按钮......然后......信息返回到屏幕(从 SQL)然后...计算机名称被放入命令行(作为 rc - 在 .java 页面中)并且网络应用程序显示远程命令的可能性 - 作为一个按钮......例如“单击按钮以执行 abc.exe在电脑名称 xxx-xxxxxx 上

所以,我需要将 IT 组用户的 IP 地址合并到命令行中……

注意:在目标上运行命令很简单 bc - 服务器打开 cmd 并执行 psexec 以在目标上执行 .exe 但是,在此示例中,服务器需要在用户上运行 cmd - 在用户 pc 上打开 gui -将目标电脑设置为 rc.exe 中的参数...

所以...示例一:用户->服务器->目标和..示例二:用户->服务器->用户->目标

谢谢你。

这是启动 setRun 的按钮:

<td>
    <form name="rc" action="index.jsp" />
    Remote Control:<input type="submit" value="${UserDetails.Computer_Name}" onsubmit=jsp:setProperty name="rc"/>
</form>               
</td>
4

0 回答 0