Skip to content

Commit 8aa0c1d

Browse files
committed
Specify /D for cmd.exe to bypass the Command Processor Autorun folder
1 parent a5d1ab2 commit 8aa0c1d

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/main/java/org/codehaus/plexus/util/cli/shell/CmdShell.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class CmdShell extends Shell {
3232
public CmdShell() {
3333
setShellCommand("cmd.exe");
3434
setQuotedExecutableEnabled(true);
35-
setShellArgs(new String[] {"/X", "/C"});
35+
setShellArgs(new String[] {"/X", "/D", "/C"});
3636
}
3737

3838
/**

src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,15 @@ public void testGetShellCommandLineWindows() throws Exception {
182182
cmd.addArguments(new String[] {"a", "b"});
183183
String[] shellCommandline = cmd.getShellCommandline();
184184

185-
assertEquals(4, shellCommandline.length, "Command line size");
185+
assertEquals(5, shellCommandline.length, "Command line size");
186186

187187
assertEquals("cmd.exe", shellCommandline[0]);
188188
assertEquals("/X", shellCommandline[1]);
189-
assertEquals("/C", shellCommandline[2]);
189+
assertEquals("/D", shellCommandline[2]);
190+
assertEquals("/C", shellCommandline[3]);
190191
String expectedShellCmd = "\"c:" + File.separator + "Program Files" + File.separator + "xxx\" a b";
191192
expectedShellCmd = "\"" + expectedShellCmd + "\"";
192-
assertEquals(expectedShellCmd, shellCommandline[3]);
193+
assertEquals(expectedShellCmd, shellCommandline[4]);
193194
}
194195

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

207-
assertEquals(4, shellCommandline.length, "Command line size");
208+
assertEquals(5, shellCommandline.length, "Command line size");
208209

209210
assertEquals("cmd.exe", shellCommandline[0]);
210211
assertEquals("/X", shellCommandline[1]);
211-
assertEquals("/C", shellCommandline[2]);
212+
assertEquals("/D", shellCommandline[2]);
213+
assertEquals("/C", shellCommandline[3]);
212214
String expectedShellCmd = "\"c:" + File.separator + "Program Files" + File.separator
213215
+ "xxx\" \"c:\\Documents and Settings\\whatever\" b";
214216
expectedShellCmd = "\"" + expectedShellCmd + "\"";
215-
assertEquals(expectedShellCmd, shellCommandline[3]);
217+
assertEquals(expectedShellCmd, shellCommandline[4]);
216218
}
217219

218220
/**

src/test/java/org/codehaus/plexus/util/cli/shell/BourneShellTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ public void testArgumentsWithsemicolon() {
205205

206206
assertEquals("cmd.exe", lines[0]);
207207
assertEquals("/X", lines[1]);
208-
assertEquals("/C", lines[2]);
209-
assertEquals("\"--password ;password\"", lines[3]);
208+
assertEquals("/D", lines[2]);
209+
assertEquals("/C", lines[3]);
210+
assertEquals("\"--password ;password\"", lines[4]);
210211
}
211212

212213
/**

0 commit comments

Comments
 (0)