Skip to content

Commit c97481c

Browse files
authored
Merge pull request #2730 from MOBergeron/additional-windows-environ-variables
Added new Windows environment variable 'SystemDrive'
2 parents d772c85 + 7d017f5 commit c97481c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cmd/incus-agent/os_windows.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,15 @@ func osExitStatus(err error) (int, error) {
238238

239239
func osSetEnv(post *api.InstanceExecPost, env map[string]string) {
240240
// SystemRoot is already set by default
241-
env["WINDIR"] = "C:\\WINDOWS"
242-
env["TMP"] = "C:\\WINDOWS\\Temp"
241+
env["SystemDrive"] = "C:"
242+
env["WINDIR"] = fmt.Sprintf("%s\\WINDOWS", env["SystemDrive"])
243+
system32 := fmt.Sprintf("%s\\System32", env["WINDIR"])
244+
env["TMP"] = fmt.Sprintf("%s\\Temp", env["WINDIR"])
243245
env["TEMP"] = env["TMP"]
244-
env["PATH"] = "C:\\WINDOWS\\System32;C:\\WINDOWS;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0"
246+
env["PATH"] = fmt.Sprintf("%s;%s;%s\\WindowsPowerShell\\v1.0", system32, env["WINDIR"], system32)
245247

246248
// Set the default working directory.
247249
if post.Cwd == "" {
248-
post.Cwd = "C:\\Windows\\System32"
250+
post.Cwd = system32
249251
}
250252
}

0 commit comments

Comments
 (0)