Open AlexFly666 opened 4 years ago
My code `public String executePsList(final List command) {
WinRmClientContext context = WinRmClientContext.newInstance(); WinRmTool tool = WinRmTool.Builder.builder(ip, username, password). setAuthenticationScheme(AuthSchemes.NTLM).port(DEFAULT_PORT). useHttps(false).build(); tool.setOperationTimeout(50000L); WinRmToolResponse resp = tool.executePs(command); context.shutdown(); return resp.getStdOut(); } public static void main(String[] args) { WinRMHelper exec = new WinRMHelper("10.0.50.110","cuizhibina","123456"); String dir = exec.executePs("Dir C:\\Users\\cuizhibina\\Desktop\\WindowsNoEditortiaoyuedexiaoren"); System.out.println("【文件夹内容】:"+dir); List<String> commandList2 = new ArrayList<>(); commandList2.add("Set-Location -Path C:\\Program Files (x86)\\Tencent\\WeChat\\"); commandList2.add(".\\WeChat.exe"); String exe = exec.executePsList(commandList2); System.out.println("【exe执行结果】:"+exe); }`
The response
`11:07:18.834 [main] INFO o.a.c.w.s.f.ReflectionServiceFactoryBean - [buildServiceFromWSDL,390] - Creating Service {http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd}WinRmService from WSDL: jar:file:/D:/JT/java/maven/m2/repository/io/cloudsoft/windows/winrm4j-client/0.9.0/winrm4j-client-0.9.0.jar!/wsdl/WinRmService.wsdl 【文件夹内容】:
??: C:\Users\cuizhibina\Desktop\WindowsNoEditortiaoyuedexiaoren
Mode LastWriteTime Length Name
d----- 2020/6/2 14:04 Engine d----- 2020/6/2 14:05 thidperson -a---- 2020/5/21 8:35 10691 Manifest_NonUFSFiles_Win64.txt -a---- 2020/7/28 15:34 1332 thidperson - ????8886.lnk -a---- 2020/6/3 13:42 1351 thidperson -8888.lnk -a---- 2020/6/3 14:22 1351 thidperson -8889.lnk -a---- 2020/5/21 8:34 189440 thidperson.exe
11:07:46.859 [main] INFO o.a.c.w.s.f.ReflectionServiceFactoryBean - [buildServiceFromWSDL,390] - Creating Service {http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd}WinRmService from WSDL: jar:file:/D:/JT/java/maven/m2/repository/io/cloudsoft/windows/winrm4j-client/0.9.0/winrm4j-client-0.9.0.jar!/wsdl/WinRmService.wsdl 【exe执行结果】:`
In the afternoon , I use ` public String executePs(final String command) { WinRmClientContext context = WinRmClientContext.newInstance(); WinRmTool tool = WinRmTool.Builder.builder(ip, username, password). authenticationScheme(AuthSchemes.NTLM).port(DEFAULT_PORT).useHttps(false).context(context).build(); tool.setOperationTimeout(50000L); WinRmToolResponse resp = tool.executePs(command); context.shutdown(); return resp.getStdOut(); }
public static void main(String[] args) {
WinRMHelper exec = new WinRMHelper("10.0.50.162","FLY","00000");
// 4.执行exe文件
String exe = exec.executePs("start D:\\test\\WindowsNoEditortiaoyuedexiaoren\\thidperson\\Binaries\\Win64\\thidperson.exe" );
System.out.println("【执行exe文件】:"+exe);
}`
yet not run exe file
My code `public String executePsList(final List command) {
The response
`11:07:18.834 [main] INFO o.a.c.w.s.f.ReflectionServiceFactoryBean - [buildServiceFromWSDL,390] - Creating Service {http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd}WinRmService from WSDL: jar:file:/D:/JT/java/maven/m2/repository/io/cloudsoft/windows/winrm4j-client/0.9.0/winrm4j-client-0.9.0.jar!/wsdl/WinRmService.wsdl 【文件夹内容】:
Mode LastWriteTime Length Name
d----- 2020/6/2 14:04 Engine
d----- 2020/6/2 14:05 thidperson
-a---- 2020/5/21 8:35 10691 Manifest_NonUFSFiles_Win64.txt
-a---- 2020/7/28 15:34 1332 thidperson - ????8886.lnk
-a---- 2020/6/3 13:42 1351 thidperson -8888.lnk
-a---- 2020/6/3 14:22 1351 thidperson -8889.lnk
-a---- 2020/5/21 8:34 189440 thidperson.exe
11:07:46.859 [main] INFO o.a.c.w.s.f.ReflectionServiceFactoryBean - [buildServiceFromWSDL,390] - Creating Service {http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd}WinRmService from WSDL: jar:file:/D:/JT/java/maven/m2/repository/io/cloudsoft/windows/winrm4j-client/0.9.0/winrm4j-client-0.9.0.jar!/wsdl/WinRmService.wsdl 【exe执行结果】:`