How can I get grub2 to boot a different option only on the next boot?

You need to make sure you have GRUB_DEFAULT=saved in your grub config (which is autogenerated, you change this part of it by editing /etc/default/grub). sudo update-grub to make the changes active and then use sudo grub-reboot $1.

grep -i "menuentry '" /boot/grub/grub.cfg

Will give you the menuentries that you can cut-paste in for $1. Or, as you note the options are zero-indexed, so the n-th menuentry can be had by passing (n-1) to grub-reboot.

See eg

  • How to reboot into Windows from Ubuntu?
  • https://unix.stackexchange.com/questions/43196/how-can-i-tell-grub-i-want-to-reboot-into-windows-before-i-reboot
  • https://superuser.com/questions/285755/boot-to-windows-once-from-grub-then-back-to-ubuntu-on-next-boot.

Not tested by me as I don't have a 'Windows 7' install.