mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-02 14:31:31 +01:00
cli: fix command prompt showing up on windows (#194946)
cli: fix wsl prompt up on windows machine Fixes #190425 again
This commit is contained in:
@@ -14,7 +14,9 @@ use crate::tunnels::paths::{get_server_folder_name, SERVER_FOLDER_NAME};
|
||||
use crate::update_service::{
|
||||
unzip_downloaded_release, Platform, Release, TargetKind, UpdateService,
|
||||
};
|
||||
use crate::util::command::{capture_command, capture_command_and_check_status, kill_tree};
|
||||
use crate::util::command::{
|
||||
capture_command, capture_command_and_check_status, kill_tree, new_script_command,
|
||||
};
|
||||
use crate::util::errors::{wrap, AnyError, CodeError, ExtensionInstallFailed, WrappedError};
|
||||
use crate::util::http::{self, BoxedHttp};
|
||||
use crate::util::io::SilentCopyProgress;
|
||||
@@ -587,17 +589,7 @@ impl<'a> ServerBuilder<'a> {
|
||||
}
|
||||
|
||||
fn get_base_command(&self) -> Command {
|
||||
#[cfg(not(windows))]
|
||||
let mut cmd = Command::new(&self.server_paths.executable);
|
||||
#[cfg(windows)]
|
||||
let mut cmd = {
|
||||
let mut cmd = Command::new("cmd");
|
||||
cmd.arg("/Q");
|
||||
cmd.arg("/C");
|
||||
cmd.arg(&self.server_paths.executable);
|
||||
cmd
|
||||
};
|
||||
|
||||
let mut cmd = new_script_command(&self.server_paths.executable);
|
||||
cmd.stdin(std::process::Stdio::null())
|
||||
.args(self.server_params.code_server_args.command_arguments());
|
||||
cmd
|
||||
|
||||
@@ -12,6 +12,7 @@ use crate::state::LauncherPaths;
|
||||
use crate::tunnels::protocol::{HttpRequestParams, METHOD_CHALLENGE_ISSUE};
|
||||
use crate::tunnels::socket_signal::CloseReason;
|
||||
use crate::update_service::{Platform, Release, TargetKind, UpdateService};
|
||||
use crate::util::command::new_tokio_command;
|
||||
use crate::util::errors::{
|
||||
wrap, AnyError, CodeError, MismatchedLaunchModeError, NoAttachedServerError,
|
||||
};
|
||||
@@ -1019,7 +1020,7 @@ where
|
||||
};
|
||||
}
|
||||
|
||||
let mut p = tokio::process::Command::new(¶ms.command);
|
||||
let mut p = new_tokio_command(¶ms.command);
|
||||
p.args(¶ms.args);
|
||||
p.envs(¶ms.env);
|
||||
p.stdin(pipe_if!(stdin.is_some()));
|
||||
@@ -1060,7 +1061,7 @@ async fn handle_spawn_cli(
|
||||
"requested to spawn cli {} with args {:?}", params.command, params.args
|
||||
);
|
||||
|
||||
let mut p = tokio::process::Command::new(¶ms.command);
|
||||
let mut p = new_tokio_command(¶ms.command);
|
||||
p.args(¶ms.args);
|
||||
|
||||
// CLI args to spawn a server; contracted with clients that they should _not_ provide these.
|
||||
|
||||
@@ -6,13 +6,11 @@
|
||||
use async_trait::async_trait;
|
||||
use shell_escape::windows::escape as shell_escape;
|
||||
use std::os::windows::process::CommandExt;
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
use std::{path::PathBuf, process::Stdio};
|
||||
use winapi::um::winbase::{CREATE_NEW_PROCESS_GROUP, DETACHED_PROCESS};
|
||||
use winreg::{enums::HKEY_CURRENT_USER, RegKey};
|
||||
|
||||
use crate::util::command::new_std_command;
|
||||
use crate::{
|
||||
constants::TUNNEL_ACTIVITY_NAME,
|
||||
log,
|
||||
@@ -54,7 +52,7 @@ impl CliServiceManager for WindowsService {
|
||||
let key = WindowsService::open_key()?;
|
||||
|
||||
let mut reg_str = String::new();
|
||||
let mut cmd = Command::new(&exe);
|
||||
let mut cmd = new_std_command(&exe);
|
||||
reg_str.push_str(shell_escape(exe.to_string_lossy()).as_ref());
|
||||
|
||||
let mut add_arg = |arg: &str| {
|
||||
@@ -102,7 +100,7 @@ impl CliServiceManager for WindowsService {
|
||||
// Start as a hidden subprocess to avoid showing cmd.exe on startup.
|
||||
// Fixes https://github.com/microsoft/vscode/issues/184058
|
||||
// I also tried the winapi ShowWindow, but that didn't yield fruit.
|
||||
Command::new(std::env::current_exe().unwrap())
|
||||
new_std_command(std::env::current_exe().unwrap())
|
||||
.args(std::env::args().skip(1))
|
||||
.env(DID_LAUNCH_AS_HIDDEN_PROCESS, "1")
|
||||
.stderr(Stdio::null())
|
||||
|
||||
@@ -12,7 +12,9 @@ pub fn is_wsl_installed(_log: &log::Logger) -> bool {
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn is_wsl_installed(log: &log::Logger) -> bool {
|
||||
use std::{path::PathBuf, process::Command};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::util::command::new_std_command;
|
||||
|
||||
let system32 = {
|
||||
let sys_root = match std::env::var("SystemRoot") {
|
||||
@@ -37,7 +39,7 @@ pub fn is_wsl_installed(log: &log::Logger) -> bool {
|
||||
// Windows builds >= 22000
|
||||
let maybe_wsl = system32.join("wsl.exe");
|
||||
if maybe_wsl.exists() {
|
||||
if let Ok(s) = Command::new(maybe_wsl).arg("--status").output() {
|
||||
if let Ok(s) = new_std_command(maybe_wsl).arg("--status").output() {
|
||||
if s.status.success() {
|
||||
trace!(log, "wsl availability detected via subprocess");
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user