Skip to content

Commit 41c3073

Browse files
committed
Expose single command execute methods
1 parent 37cd4bc commit 41c3073

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+
* @param commands
31+
* @deprecated since 0.2; Use the {@link #executeCommand(String)} instead and transform your commands list explicitly
32+
*/
33+
@Deprecated
2734
public WinRmToolResponse executeScript(List<String> commands) {
2835
Response response = session.run_cmd(compileScript(commands));
2936
return responseToWinRmToolResponse(response);
3037
}
3138

32-
public WinRmToolResponse executePs(List<String> commands) {
33-
Response response = session.run_ps(compileScript(commands));
39+
/**
40+
* Executes a Native Windows command.
41+
* It is creating a new Shell on the destination host each time it is being called.
42+
* @param command
43+
* @since 0.2
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+
* @param psCommands
54+
* @deprecated since 0.2; Use the {@link #executePsCommand(String)} instead and transform your commands list explicitly
55+
*/
56+
@Deprecated
57+
public WinRmToolResponse executePsScript(List<String> psCommands) {
58+
Response response = session.run_ps(compileScript(psCommands));
59+
return responseToWinRmToolResponse(response);
60+
}
61+
62+
/**
63+
* Executes a Power Shell command.
64+
* It is creating a new Shell on the destination host each time it is being called.
65+
* @param psCommand
66+
* @since 0.2
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)