Use WINDIR instead of hardcoding C:\Windows

This commit is contained in:
widberg
2024-01-11 11:57:25 -05:00
committed by Mitchell Hashimoto
parent 2698852f08
commit de71e992ec

View File

@ -1042,7 +1042,17 @@ const Subprocess = struct {
if (comptime builtin.os.tag == .windows) { if (comptime builtin.os.tag == .windows) {
// We run our shell wrapped in `cmd.exe` so that we don't have // We run our shell wrapped in `cmd.exe` so that we don't have
// to parse the command line ourselves if it has arguments. // to parse the command line ourselves if it has arguments.
try args.append("C:\\Windows\\System32\\cmd.exe");
// Note we don't free any of the memory below since it is
// allocated in the arena.
const windir = try std.process.getEnvVarOwned(alloc, "WINDIR");
const cmd = try std.fs.path.join(alloc, &[_][]const u8{
windir,
"System32",
"cmd.exe",
});
try args.append(cmd);
try args.append("/C"); try args.append("/C");
} else { } else {
// We run our shell wrapped in `/bin/sh` so that we don't have // We run our shell wrapped in `/bin/sh` so that we don't have