Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify /D for cmd.exe to bypass the Command Processor Autorun folder #272

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class CmdShell extends Shell {
public CmdShell() {
setShellCommand("cmd.exe");
setQuotedExecutableEnabled(true);
setShellArgs(new String[] {"/X", "/C"});
setShellArgs(new String[] {"/X", "/D", "/C"});
}

/**
Expand Down
14 changes: 8 additions & 6 deletions src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,15 @@ public void testGetShellCommandLineWindows() throws Exception {
cmd.addArguments(new String[] {"a", "b"});
String[] shellCommandline = cmd.getShellCommandline();

assertEquals(4, shellCommandline.length, "Command line size");
assertEquals(5, shellCommandline.length, "Command line size");

assertEquals("cmd.exe", shellCommandline[0]);
assertEquals("/X", shellCommandline[1]);
assertEquals("/C", shellCommandline[2]);
assertEquals("/D", shellCommandline[2]);
assertEquals("/C", shellCommandline[3]);
String expectedShellCmd = "\"c:" + File.separator + "Program Files" + File.separator + "xxx\" a b";
expectedShellCmd = "\"" + expectedShellCmd + "\"";
assertEquals(expectedShellCmd, shellCommandline[3]);
assertEquals(expectedShellCmd, shellCommandline[4]);
}

/**
Expand All @@ -204,15 +205,16 @@ public void testGetShellCommandLineWindowsWithSeveralQuotes() throws Exception {
cmd.addArguments(new String[] {"c:\\Documents and Settings\\whatever", "b"});
String[] shellCommandline = cmd.getShellCommandline();

assertEquals(4, shellCommandline.length, "Command line size");
assertEquals(5, shellCommandline.length, "Command line size");

assertEquals("cmd.exe", shellCommandline[0]);
assertEquals("/X", shellCommandline[1]);
assertEquals("/C", shellCommandline[2]);
assertEquals("/D", shellCommandline[2]);
assertEquals("/C", shellCommandline[3]);
String expectedShellCmd = "\"c:" + File.separator + "Program Files" + File.separator
+ "xxx\" \"c:\\Documents and Settings\\whatever\" b";
expectedShellCmd = "\"" + expectedShellCmd + "\"";
assertEquals(expectedShellCmd, shellCommandline[3]);
assertEquals(expectedShellCmd, shellCommandline[4]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ public void testArgumentsWithsemicolon() {

assertEquals("cmd.exe", lines[0]);
assertEquals("/X", lines[1]);
assertEquals("/C", lines[2]);
assertEquals("\"--password ;password\"", lines[3]);
assertEquals("/D", lines[2]);
assertEquals("/C", lines[3]);
assertEquals("\"--password ;password\"", lines[4]);
}

/**
Expand Down