Change the way we detect Windows admin permission

This commit is contained in:
2020-11-23 14:14:03 -05:00
parent e1f29f72e1
commit 3dec337272
2 changed files with 7 additions and 6 deletions

View File

@@ -20,9 +20,11 @@ os_is_windows is_windows
os_is_macos is_macos
os_is_linux is_linux
# Check for admin permissions when running on Windows.
if [[ $is_windows -eq 1 ]]; then
# Check for admin permissions.
net session &>/dev/null
# `openfiles` is a command present on all supported Windows versions,
# requires admin privileges, and has no side effects.
openfiles &>/dev/null
admin_error=$?
if [[ ! $admin_error -eq 0 ]]; then
fatal "You need to run this in an admin shell!"