Fix symlink creation on older Windows versions
This patch ensures that the `SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE` flag is not passed to `CreateSymbolicLinkW` when the developer mode registry key is not present and enabled on a supported version of Windows. This allows symlinks to be created when Bazel is run with elevated privileges, regardless of Windows version or developer mode.
I also removed the dummy file creation check while refactoring that code for reuse. It seemed overly complicated vs. simply checking the registry and failing during runfiles creation if we're not admin. Please let me know if there's some subtle reason it needed to be done that way.
Fixes #13169 - tested on Windows Server 2016.
Closes #13488.
PiperOrigin-RevId: 375035407
diff --git a/tools/jdk/BUILD.java_tools b/tools/jdk/BUILD.java_tools
index 3a7d841..cabc2db 100644
--- a/tools/jdk/BUILD.java_tools
+++ b/tools/jdk/BUILD.java_tools
@@ -308,6 +308,9 @@
"java_tools/src/main/native/windows/file.h",
"java_tools/src/main/native/windows/util.h",
],
+ linkopts = [
+ "-DEFAULTLIB:advapi32.lib",
+ ],
strip_include_prefix = "java_tools",
)