Skip to content

Commit 8f8f899

Browse files
committed
Expose single command execute methods
1 parent 37cd4bc commit 8f8f899

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

src/main/java/io/cloudsoft/winrm4j/winrm/WinRmTool.java

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,49 @@ public static WinRmTool connect(String address, String username, String password
2424
return tool;
2525
}
2626

27+
/**
28+
* Execute a list of Windows Native commands as one command.
29+
* The method translates the list of commands to a single String command with a <code>"\r\n"</code> delimiter and a terminating one.
30+
* It is creating a new Shell on the destination host each time it is being called.
31+
* @param commands
32+
* @deprecated use the {@link #executeCommand} instead and transform your commands list explicitly
33+
*/
34+
@Deprecated
2735
public WinRmToolResponse executeScript(List<String> commands) {
2836
Response response = session.run_cmd(compileScript(commands));
2937
return responseToWinRmToolResponse(response);
3038
}
3139

32-
public WinRmToolResponse executePs(List<String> commands) {
33-
Response response = session.run_ps(compileScript(commands));
40+
/**
41+
* Executes a Native Windows command.
42+
* It is creating a new Shell on the destination host each time it is being called.
43+
* @param command
44+
*/
45+
public WinRmToolResponse executeCommand(String command) {
46+
Response response = session.run_cmd(command);
47+
return responseToWinRmToolResponse(response);
48+
}
49+
50+
/**
51+
* Execute a list of Power Shell commands as one command.
52+
* The method translates the list of commands to a single String command with a <code>"\r\n"</code> delimiter and a terminating one.
53+
* It is creating a new Shell on the destination host each time it is being called
54+
* @param psCommands
55+
* @deprecated use the {@link #executePsCommand} instead and transform your commands list explicitly
56+
*/
57+
@Deprecated
58+
public WinRmToolResponse executePsScript(List<String> psCommands) {
59+
Response response = session.run_ps(compileScript(psCommands));
60+
return responseToWinRmToolResponse(response);
61+
}
62+
63+
/**
64+
* Executes a Power Shell command.
65+
* It is creating a new Shell on the destination host each time it is being called.
66+
* @param psCommand
67+
*/
68+
public WinRmToolResponse executePsCommand(String psCommand) {
69+
Response response = session.run_ps(psCommand);
3470
return responseToWinRmToolResponse(response);
3571
}
3672

0 commit comments

Comments
 (0)