Skip to content

Instantly share code, notes, and snippets.

@shello
Created June 18, 2024 17:46
Show Gist options
  • Save shello/6cd4e7a0f963ce7855b4ee413796480c to your computer and use it in GitHub Desktop.
Save shello/6cd4e7a0f963ce7855b4ee413796480c to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
target_boot_name='Windows Boot Manager'
windows_boot_id="$(efibootmgr --unicode | grep "$target_boot_name" | sed 's/Boot\([0-9a-fA-F]\{4\}\)\*\? .*/\1/')"
if [ ${#windows_boot_id} -ne 4 ]; then
echo "$0: Could not find boot id for Windows."
exit 1
fi
if ! sudo efibootmgr -n "$windows_boot_id"; then
echo "$0: Could not set NextBoot with efibootmgr." >&2
exit 1
fi
sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment