diff --git a/server/src/index.ts b/server/src/index.ts index bdfe49019..82158ba73 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -436,7 +436,14 @@ const createTransport = async ( if (transportType === "stdio") { const command = (query.command as string).trim(); - const origArgs = shellParseArgs(query.args as string) as string[]; + // shell-quote's default escape character `\` strips backslashes from Windows + // paths (C:\Users\app.jar -> C:Usersapp.jar), so on Windows parse with + // cmd.exe's escape character `^` instead. + const origArgs = shellParseArgs( + query.args as string, + undefined, + process.platform === "win32" ? { escape: "^" } : undefined, + ) as string[]; const queryEnv = query.env ? JSON.parse(query.env as string) : {}; const env = { ...defaultEnvironment, ...process.env, ...queryEnv };