Skip to content

Commit 02f03ee

Browse files
Disable powershell v2 stuff
Seems it's returning "null" or "PowerShell x.y.z" values
1 parent 4f73df4 commit 02f03ee

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

src/main/java/dev/dirs/impl/Windows.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,29 +117,12 @@ private static String[] runWinCommands(int guidsLength, String[] dirs, String en
117117
File commandFile = new File(dir, command);
118118
if (commandFile.exists()) {
119119
try {
120-
String[] stdout;
121-
// try to run using powershell V2 to bypass constrained language mode
122-
// note that this has been deprecated in new version of Windows
123-
// https://devblogs.microsoft.com/powershell/windows-powershell-2-0-deprecation/
124-
// for some set up, running this requires installation of extra dependency on Windows host
125-
stdout = runCommands(guidsLength, Charset.forName("UTF-8"),
120+
return runCommands(guidsLength, Charset.forName("UTF-8"),
126121
commandFile.toString(),
127-
"-version",
128-
"2",
129122
"-NoProfile",
130123
"-EncodedCommand",
131124
encodedCommand
132125
);
133-
if (stdout[0] != null) return stdout;
134-
135-
// fall-forward to higher version of powershell
136-
stdout = runCommands(guidsLength, Charset.forName("UTF-8"),
137-
commandFile.toString(),
138-
"-NoProfile",
139-
"-EncodedCommand",
140-
encodedCommand
141-
);
142-
return stdout;
143126
} catch (IOException e) {
144127
firstException = firstException == null ? e : firstException;
145128
}

src/test/java/dev/dirs/impl/UtilTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ public void testPowershellBase64StringIsNotPadded() {
181181
}
182182
}
183183

184+
@Test
185+
public void testPowershellOne() {
186+
if (Constants.operatingSystem == 'w') {
187+
String[] winDirs = Windows.getWinDirs("3EB685DB-65F9-4CF6-A03A-E3EF65729F3D");
188+
for (String winDir : winDirs) {
189+
assertNotNull(winDir);
190+
}
191+
}
192+
}
193+
184194
@Test
185195
public void testPowershell() {
186196
if (Constants.operatingSystem == 'w') {

0 commit comments

Comments
 (0)