diff --git a/third_party/remote_config/common.bzl b/third_party/remote_config/common.bzl
index d7e69326205..e12effb3449 100644
--- a/third_party/remote_config/common.bzl
+++ b/third_party/remote_config/common.bzl
@@ -24,10 +24,12 @@ def which(repository_ctx, program_name):
     if is_windows(repository_ctx):
         if not program_name.endswith(".exe"):
             program_name = program_name + ".exe"
-        result = execute(repository_ctx, ["C:\\Windows\\System32\\where.exe", program_name])
-    else:
-        result = execute(repository_ctx, ["which", program_name])
-    return result.stdout.rstrip()
+        return execute(
+            repository_ctx,
+            ["C:\\Windows\\System32\\where.exe", program_name],
+        ).stdout.replace("\\", "\\\\").rstrip()
+
+    return execute(repository_ctx, ["which", program_name]).stdout.rstrip()
 
 def get_python_bin(repository_ctx):
     """Gets the python bin path.