Skip to content

Commit 29290aa

Browse files
committed
Revert "[rust] Improve logic to locate wmic.exe in Windows"
This reverts commit 2c45d7c.
1 parent 59a25c7 commit 29290aa

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

.bazelrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ test --test_env=JRUBY_OPTS="--dev"
9393
test:windows --test_env=LOCALAPPDATA
9494
test:windows --test_env=PROGRAMFILES="C:\\Program Files"
9595
test:windows --test_env=PROGRAMFILES(X86)="C:\\Program Files (x86)"
96-
test:windows --test_env=SYSTEMROOT="C:\\Windows"
9796

9897
test --test_timeout=1800
9998

rust/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use crate::config::OS::{LINUX, MACOS, WINDOWS};
1919
use crate::shell::run_shell_command_by_os;
2020
use crate::{
21-
default_cache_folder, format_one_arg, get_wmic, path_to_string, Command, REQUEST_TIMEOUT_SEC,
21+
default_cache_folder, format_one_arg, path_to_string, Command, REQUEST_TIMEOUT_SEC,
2222
UNAME_COMMAND,
2323
};
2424
use crate::{ARCH_AMD64, ARCH_ARM64, ARCH_X86, TTL_SEC, WMIC_COMMAND_OS};
@@ -66,7 +66,7 @@ impl ManagerConfig {
6666

6767
let self_os = OS;
6868
let self_arch = if WINDOWS.is(self_os) {
69-
let wmic_command = Command::new_single(format_one_arg(WMIC_COMMAND_OS, &get_wmic()));
69+
let wmic_command = Command::new_single(WMIC_COMMAND_OS.to_string());
7070
let wmic_output = run_shell_command_by_os(self_os, wmic_command).unwrap_or_default();
7171
if wmic_output.contains("32") {
7272
ARCH_X86.to_string()

rust/src/lib.rs

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ pub const DEV: &str = "dev";
7474
pub const CANARY: &str = "canary";
7575
pub const NIGHTLY: &str = "nightly";
7676
pub const ESR: &str = "esr";
77-
pub const WMIC: &str = "wmic";
78-
pub const WMIC_DEFAULT_PATH: &str = r#"{}\System32\Wbem\WMIC.exe"#;
79-
pub const WMIC_COMMAND: &str = r#"{} datafile where name='{}' get Version /value"#;
80-
pub const WMIC_COMMAND_OS: &str = r#"{} os get osarchitecture"#;
77+
pub const WMIC_COMMAND: &str = r#"wmic datafile where name='{}' get Version /value"#;
78+
pub const WMIC_COMMAND_OS: &str = r#"wmic os get osarchitecture"#;
8179
pub const REG_VERSION_ARG: &str = "version";
8280
pub const REG_CURRENT_VERSION_ARG: &str = "CurrentVersion";
8381
pub const REG_PV_ARG: &str = "pv";
@@ -95,7 +93,6 @@ pub const SINGLE_QUOTE: &str = "'";
9593
pub const ENV_PROGRAM_FILES: &str = "PROGRAMFILES";
9694
pub const ENV_PROGRAM_FILES_X86: &str = "PROGRAMFILES(X86)";
9795
pub const ENV_LOCALAPPDATA: &str = "LOCALAPPDATA";
98-
pub const ENV_SYSTEMROOT: &str = "SYSTEMROOT";
9996
pub const ENV_X86: &str = " (x86)";
10097
pub const ARCH_X86: &str = "x86";
10198
pub const ARCH_AMD64: &str = "amd64";
@@ -1076,11 +1073,8 @@ pub trait SeleniumManager {
10761073

10771074
if WINDOWS.is(self.get_os()) {
10781075
if !escaped_browser_path.is_empty() {
1079-
let wmic_command = Command::new_single(format_two_args(
1080-
WMIC_COMMAND,
1081-
&get_wmic(),
1082-
&escaped_browser_path,
1083-
));
1076+
let wmic_command =
1077+
Command::new_single(format_one_arg(WMIC_COMMAND, &escaped_browser_path));
10841078
commands.push(wmic_command);
10851079
}
10861080
if !self.is_browser_version_unstable() {
@@ -1555,19 +1549,6 @@ pub fn format_three_args(string: &str, arg1: &str, arg2: &str, arg3: &str) -> St
15551549
.replacen("{}", arg3, 1)
15561550
}
15571551

1558-
pub fn get_wmic() -> String {
1559-
let system_root = env::var(ENV_SYSTEMROOT).unwrap_or_default();
1560-
let wmic_default_path = format_one_arg(WMIC_DEFAULT_PATH, &system_root);
1561-
let wmic_path = Path::new(&wmic_default_path);
1562-
if !wmic_path.exists() {
1563-
return match which(WMIC) {
1564-
Ok(path) => path_to_string(&path),
1565-
Err(_) => WMIC.to_string(),
1566-
};
1567-
}
1568-
path_to_string(wmic_path)
1569-
}
1570-
15711552
// ----------------------------------------------------------
15721553
// Private functions
15731554
// ----------------------------------------------------------

0 commit comments

Comments
 (0)