How can I create a shortcut between Ubuntu 16 and Windows 10 on a dualboot? [duplicate]
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
This question already has an answer here:
How to reboot into Windows from Ubuntu?
8 answers
I'm looking for a one-click shortcut to log out, restart, and boot in the opposite operating system. The only information I've found online is between Windows and Windows and I'm not sure if it's different.
dual-boot shortcuts
marked as duplicate by muru, karel, Eric Carvalho, Zanna, A J Mar 22 at 19:08
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
 |Â
show 1 more comment
up vote
1
down vote
favorite
This question already has an answer here:
How to reboot into Windows from Ubuntu?
8 answers
I'm looking for a one-click shortcut to log out, restart, and boot in the opposite operating system. The only information I've found online is between Windows and Windows and I'm not sure if it's different.
dual-boot shortcuts
marked as duplicate by muru, karel, Eric Carvalho, Zanna, A J Mar 22 at 19:08
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
Logout and reboot is simple. Just write a script with thereboot
command. The trick is making GRUB boot another OS next time. This is explained here and especially here.
â PerlDuck
Mar 19 at 17:12
1
Maybe this might help? askubuntu.com/a/859530/231142
â Terrance
Mar 19 at 17:20
1
@Terrance, your solution is a really great and simple one. It doesn't even require fiddling around with the /etc/default/grub file.
â PerlDuck
Mar 19 at 17:25
If you make a bash script to do what @Terrance suggested (which should only need two lines; I have done it before), you might be able to use a launcher to run it.
â Andrew Shum
Mar 19 at 19:06
Just found this which should help with being able to use a launcher.
â Andrew Shum
Mar 19 at 19:30
 |Â
show 1 more comment
up vote
1
down vote
favorite
up vote
1
down vote
favorite
This question already has an answer here:
How to reboot into Windows from Ubuntu?
8 answers
I'm looking for a one-click shortcut to log out, restart, and boot in the opposite operating system. The only information I've found online is between Windows and Windows and I'm not sure if it's different.
dual-boot shortcuts
This question already has an answer here:
How to reboot into Windows from Ubuntu?
8 answers
I'm looking for a one-click shortcut to log out, restart, and boot in the opposite operating system. The only information I've found online is between Windows and Windows and I'm not sure if it's different.
This question already has an answer here:
How to reboot into Windows from Ubuntu?
8 answers
dual-boot shortcuts
dual-boot shortcuts
asked Mar 19 at 17:03
Largobone
62
62
marked as duplicate by muru, karel, Eric Carvalho, Zanna, A J Mar 22 at 19:08
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by muru, karel, Eric Carvalho, Zanna, A J Mar 22 at 19:08
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
Logout and reboot is simple. Just write a script with thereboot
command. The trick is making GRUB boot another OS next time. This is explained here and especially here.
â PerlDuck
Mar 19 at 17:12
1
Maybe this might help? askubuntu.com/a/859530/231142
â Terrance
Mar 19 at 17:20
1
@Terrance, your solution is a really great and simple one. It doesn't even require fiddling around with the /etc/default/grub file.
â PerlDuck
Mar 19 at 17:25
If you make a bash script to do what @Terrance suggested (which should only need two lines; I have done it before), you might be able to use a launcher to run it.
â Andrew Shum
Mar 19 at 19:06
Just found this which should help with being able to use a launcher.
â Andrew Shum
Mar 19 at 19:30
 |Â
show 1 more comment
2
Logout and reboot is simple. Just write a script with thereboot
command. The trick is making GRUB boot another OS next time. This is explained here and especially here.
â PerlDuck
Mar 19 at 17:12
1
Maybe this might help? askubuntu.com/a/859530/231142
â Terrance
Mar 19 at 17:20
1
@Terrance, your solution is a really great and simple one. It doesn't even require fiddling around with the /etc/default/grub file.
â PerlDuck
Mar 19 at 17:25
If you make a bash script to do what @Terrance suggested (which should only need two lines; I have done it before), you might be able to use a launcher to run it.
â Andrew Shum
Mar 19 at 19:06
Just found this which should help with being able to use a launcher.
â Andrew Shum
Mar 19 at 19:30
2
2
Logout and reboot is simple. Just write a script with the
reboot
command. The trick is making GRUB boot another OS next time. This is explained here and especially here.â PerlDuck
Mar 19 at 17:12
Logout and reboot is simple. Just write a script with the
reboot
command. The trick is making GRUB boot another OS next time. This is explained here and especially here.â PerlDuck
Mar 19 at 17:12
1
1
Maybe this might help? askubuntu.com/a/859530/231142
â Terrance
Mar 19 at 17:20
Maybe this might help? askubuntu.com/a/859530/231142
â Terrance
Mar 19 at 17:20
1
1
@Terrance, your solution is a really great and simple one. It doesn't even require fiddling around with the /etc/default/grub file.
â PerlDuck
Mar 19 at 17:25
@Terrance, your solution is a really great and simple one. It doesn't even require fiddling around with the /etc/default/grub file.
â PerlDuck
Mar 19 at 17:25
If you make a bash script to do what @Terrance suggested (which should only need two lines; I have done it before), you might be able to use a launcher to run it.
â Andrew Shum
Mar 19 at 19:06
If you make a bash script to do what @Terrance suggested (which should only need two lines; I have done it before), you might be able to use a launcher to run it.
â Andrew Shum
Mar 19 at 19:06
Just found this which should help with being able to use a launcher.
â Andrew Shum
Mar 19 at 19:30
Just found this which should help with being able to use a launcher.
â Andrew Shum
Mar 19 at 19:30
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
NOTE: This answer has been a work in progress.
This can be done. I am not sure what Desktop Environment you are running, but the steps should be relatively close to the same. These steps will create a script that you can run from the command line and also a desktop launcher that can be launched by clicking on it. Either way, it is best to have it asking for a password before the reboot happens.
First thing is to create a script that will contain the commands based from my other answer here using grub-reboot
as it sets the default boot entry for GRUB, for the next boot only. The reason for this is so there is no editing of the /etc/default/grub
file or the /boot/grub/grub.cfg
file.
I called my script win_reboot.bsh
, but before adding the contents to the script, run sudo os-prober
to get a more precise name of the Windows 10 just in case there are multiple entries like could be found in OEM systems with recovery, etc.
I don't use GPT or run on an OEM system so I only have one entry.
terrance@terrance-ubuntu:~$ sudo os-prober
/dev/sdh1:Windows 10 (loader):Windows:chain
Take note of the Windows name between the colons :
. We are going to use the Windows 10 (loader)
. awk
will actually have a problem with special characters like ()/
so we will have to escape those with a like
Windows 10 (loader)
. We are going to use this line because it will be more precise if there are multiple entries in the os-prober
that is run before grub-update
writes a new /boot/grub/grub.cfg
file.
For this, we are also going to use the pkexec
command which should already be installed. gksu is deprecated.
Script contents:
#!/bin/bash
if [ $UID != 0 ]; then
echo "Please run as 'sudo $0'"
exit 1
fi
grub-reboot "$(awk -F"'" '/Windows 10 (loader)/ print $2' /boot/grub/grub.cfg)"
reboot
That script will search through the grub.cfg
file and get the full name of the Windows 10 (loader)
boot. I did the line to handle changes if a grub-update
is performed in the future and changes the name of that line. The reason for this is that if you add a hard drive or leave a USB drive in the system that is not bootable during a boot up, the drive designation can change. You could see a line that reads like Windows 10 (loader) (on /dev/sdh1)
then on another grub-update
it changes to Windows 10 (loader) (on /dev/sdg1)
. Good thing that these entries actually rely on the UUID
of the partition and not the name in the grub entry.
Next, make the script executable:
sudo chmod +x win_reboot.bsh
Now if you run it from the command line without sudo it should look like this:
terrance@terrance-ubuntu:~/scripts$ ./win_reboot.bsh
Please run as 'sudo ./win_reboot.bsh'
Create a shortcut to the new script. I hope that when you right-click on your desktop that Create Launcher
is one of the options. I am running Xfce4
as my desktop. I guess you could create a launcher based on the comment posted by Andrew Shum as it should still work as long as it points to the win_reboot.bsh script.
Edit: I changed the launcher here based on the comments I received below. sudo -H
does not work in the command of a launcher, unless you have set the option to Run in Terminal. One other thing to note here that this launcher is calling a CLI script and not a GUI application.
You can create a file in your ~/Desktop
folder named Boot to Windows 10.desktop
and add the following to it:
[Desktop Entry]
Version=1.0
Type=Application
Name=Boot to Windows 10
Comment=Reboot System to Windows 10
Exec=pkexec /home/terrance/scripts/win_reboot.bsh
Icon=web-microsoft
Path=
Terminal=false
StartupNotify=false
Remember to change the Exec=
line to match your file location.
Then when you launch the shortcut you will see something similar to enter your password as the Super User:
Hope this helps!
It probably won't be an issue for Largobone, but it seems like that particular solution would run into trouble if there are multiple entries for a "Windows 10". For instance, my computer at work was setup with Windows 7 by IT and somehow ended up with 3 (maybe 4) separate images; all detected by Grub yet only one is actually setup. Also, if one is going to make a launcher, shouldn't "gksudo" be used instead?
â Andrew Shum
Mar 21 at 9:37
@AndrewShum Updated based on your comment.
â Terrance
Mar 21 at 13:46
I thought gksudo was depreciated for launching gui apps. And you should not just use sudo either, current recommended method issudo -H
# which keeps /home as location of files. see askubuntu.com/questions/11760/â¦
â oldfred
Mar 21 at 13:54
@oldfred You are right. However, this is only a call to a script not a GUI application. I need to change my image and edit this answer one more time to usepkexec
instead. Thesudo -H
at this point is moot because I have tested both ways and they work fine.
â Terrance
Mar 21 at 14:15
@oldfred Thanks for sharing that information. Is it the same withsu
vsgksu
and does it necessarily impact older OSs? The specific post that mentioned it was specifically about 17 and up.
â Andrew Shum
Mar 21 at 17:45
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
NOTE: This answer has been a work in progress.
This can be done. I am not sure what Desktop Environment you are running, but the steps should be relatively close to the same. These steps will create a script that you can run from the command line and also a desktop launcher that can be launched by clicking on it. Either way, it is best to have it asking for a password before the reboot happens.
First thing is to create a script that will contain the commands based from my other answer here using grub-reboot
as it sets the default boot entry for GRUB, for the next boot only. The reason for this is so there is no editing of the /etc/default/grub
file or the /boot/grub/grub.cfg
file.
I called my script win_reboot.bsh
, but before adding the contents to the script, run sudo os-prober
to get a more precise name of the Windows 10 just in case there are multiple entries like could be found in OEM systems with recovery, etc.
I don't use GPT or run on an OEM system so I only have one entry.
terrance@terrance-ubuntu:~$ sudo os-prober
/dev/sdh1:Windows 10 (loader):Windows:chain
Take note of the Windows name between the colons :
. We are going to use the Windows 10 (loader)
. awk
will actually have a problem with special characters like ()/
so we will have to escape those with a like
Windows 10 (loader)
. We are going to use this line because it will be more precise if there are multiple entries in the os-prober
that is run before grub-update
writes a new /boot/grub/grub.cfg
file.
For this, we are also going to use the pkexec
command which should already be installed. gksu is deprecated.
Script contents:
#!/bin/bash
if [ $UID != 0 ]; then
echo "Please run as 'sudo $0'"
exit 1
fi
grub-reboot "$(awk -F"'" '/Windows 10 (loader)/ print $2' /boot/grub/grub.cfg)"
reboot
That script will search through the grub.cfg
file and get the full name of the Windows 10 (loader)
boot. I did the line to handle changes if a grub-update
is performed in the future and changes the name of that line. The reason for this is that if you add a hard drive or leave a USB drive in the system that is not bootable during a boot up, the drive designation can change. You could see a line that reads like Windows 10 (loader) (on /dev/sdh1)
then on another grub-update
it changes to Windows 10 (loader) (on /dev/sdg1)
. Good thing that these entries actually rely on the UUID
of the partition and not the name in the grub entry.
Next, make the script executable:
sudo chmod +x win_reboot.bsh
Now if you run it from the command line without sudo it should look like this:
terrance@terrance-ubuntu:~/scripts$ ./win_reboot.bsh
Please run as 'sudo ./win_reboot.bsh'
Create a shortcut to the new script. I hope that when you right-click on your desktop that Create Launcher
is one of the options. I am running Xfce4
as my desktop. I guess you could create a launcher based on the comment posted by Andrew Shum as it should still work as long as it points to the win_reboot.bsh script.
Edit: I changed the launcher here based on the comments I received below. sudo -H
does not work in the command of a launcher, unless you have set the option to Run in Terminal. One other thing to note here that this launcher is calling a CLI script and not a GUI application.
You can create a file in your ~/Desktop
folder named Boot to Windows 10.desktop
and add the following to it:
[Desktop Entry]
Version=1.0
Type=Application
Name=Boot to Windows 10
Comment=Reboot System to Windows 10
Exec=pkexec /home/terrance/scripts/win_reboot.bsh
Icon=web-microsoft
Path=
Terminal=false
StartupNotify=false
Remember to change the Exec=
line to match your file location.
Then when you launch the shortcut you will see something similar to enter your password as the Super User:
Hope this helps!
It probably won't be an issue for Largobone, but it seems like that particular solution would run into trouble if there are multiple entries for a "Windows 10". For instance, my computer at work was setup with Windows 7 by IT and somehow ended up with 3 (maybe 4) separate images; all detected by Grub yet only one is actually setup. Also, if one is going to make a launcher, shouldn't "gksudo" be used instead?
â Andrew Shum
Mar 21 at 9:37
@AndrewShum Updated based on your comment.
â Terrance
Mar 21 at 13:46
I thought gksudo was depreciated for launching gui apps. And you should not just use sudo either, current recommended method issudo -H
# which keeps /home as location of files. see askubuntu.com/questions/11760/â¦
â oldfred
Mar 21 at 13:54
@oldfred You are right. However, this is only a call to a script not a GUI application. I need to change my image and edit this answer one more time to usepkexec
instead. Thesudo -H
at this point is moot because I have tested both ways and they work fine.
â Terrance
Mar 21 at 14:15
@oldfred Thanks for sharing that information. Is it the same withsu
vsgksu
and does it necessarily impact older OSs? The specific post that mentioned it was specifically about 17 and up.
â Andrew Shum
Mar 21 at 17:45
 |Â
show 1 more comment
up vote
0
down vote
NOTE: This answer has been a work in progress.
This can be done. I am not sure what Desktop Environment you are running, but the steps should be relatively close to the same. These steps will create a script that you can run from the command line and also a desktop launcher that can be launched by clicking on it. Either way, it is best to have it asking for a password before the reboot happens.
First thing is to create a script that will contain the commands based from my other answer here using grub-reboot
as it sets the default boot entry for GRUB, for the next boot only. The reason for this is so there is no editing of the /etc/default/grub
file or the /boot/grub/grub.cfg
file.
I called my script win_reboot.bsh
, but before adding the contents to the script, run sudo os-prober
to get a more precise name of the Windows 10 just in case there are multiple entries like could be found in OEM systems with recovery, etc.
I don't use GPT or run on an OEM system so I only have one entry.
terrance@terrance-ubuntu:~$ sudo os-prober
/dev/sdh1:Windows 10 (loader):Windows:chain
Take note of the Windows name between the colons :
. We are going to use the Windows 10 (loader)
. awk
will actually have a problem with special characters like ()/
so we will have to escape those with a like
Windows 10 (loader)
. We are going to use this line because it will be more precise if there are multiple entries in the os-prober
that is run before grub-update
writes a new /boot/grub/grub.cfg
file.
For this, we are also going to use the pkexec
command which should already be installed. gksu is deprecated.
Script contents:
#!/bin/bash
if [ $UID != 0 ]; then
echo "Please run as 'sudo $0'"
exit 1
fi
grub-reboot "$(awk -F"'" '/Windows 10 (loader)/ print $2' /boot/grub/grub.cfg)"
reboot
That script will search through the grub.cfg
file and get the full name of the Windows 10 (loader)
boot. I did the line to handle changes if a grub-update
is performed in the future and changes the name of that line. The reason for this is that if you add a hard drive or leave a USB drive in the system that is not bootable during a boot up, the drive designation can change. You could see a line that reads like Windows 10 (loader) (on /dev/sdh1)
then on another grub-update
it changes to Windows 10 (loader) (on /dev/sdg1)
. Good thing that these entries actually rely on the UUID
of the partition and not the name in the grub entry.
Next, make the script executable:
sudo chmod +x win_reboot.bsh
Now if you run it from the command line without sudo it should look like this:
terrance@terrance-ubuntu:~/scripts$ ./win_reboot.bsh
Please run as 'sudo ./win_reboot.bsh'
Create a shortcut to the new script. I hope that when you right-click on your desktop that Create Launcher
is one of the options. I am running Xfce4
as my desktop. I guess you could create a launcher based on the comment posted by Andrew Shum as it should still work as long as it points to the win_reboot.bsh script.
Edit: I changed the launcher here based on the comments I received below. sudo -H
does not work in the command of a launcher, unless you have set the option to Run in Terminal. One other thing to note here that this launcher is calling a CLI script and not a GUI application.
You can create a file in your ~/Desktop
folder named Boot to Windows 10.desktop
and add the following to it:
[Desktop Entry]
Version=1.0
Type=Application
Name=Boot to Windows 10
Comment=Reboot System to Windows 10
Exec=pkexec /home/terrance/scripts/win_reboot.bsh
Icon=web-microsoft
Path=
Terminal=false
StartupNotify=false
Remember to change the Exec=
line to match your file location.
Then when you launch the shortcut you will see something similar to enter your password as the Super User:
Hope this helps!
It probably won't be an issue for Largobone, but it seems like that particular solution would run into trouble if there are multiple entries for a "Windows 10". For instance, my computer at work was setup with Windows 7 by IT and somehow ended up with 3 (maybe 4) separate images; all detected by Grub yet only one is actually setup. Also, if one is going to make a launcher, shouldn't "gksudo" be used instead?
â Andrew Shum
Mar 21 at 9:37
@AndrewShum Updated based on your comment.
â Terrance
Mar 21 at 13:46
I thought gksudo was depreciated for launching gui apps. And you should not just use sudo either, current recommended method issudo -H
# which keeps /home as location of files. see askubuntu.com/questions/11760/â¦
â oldfred
Mar 21 at 13:54
@oldfred You are right. However, this is only a call to a script not a GUI application. I need to change my image and edit this answer one more time to usepkexec
instead. Thesudo -H
at this point is moot because I have tested both ways and they work fine.
â Terrance
Mar 21 at 14:15
@oldfred Thanks for sharing that information. Is it the same withsu
vsgksu
and does it necessarily impact older OSs? The specific post that mentioned it was specifically about 17 and up.
â Andrew Shum
Mar 21 at 17:45
 |Â
show 1 more comment
up vote
0
down vote
up vote
0
down vote
NOTE: This answer has been a work in progress.
This can be done. I am not sure what Desktop Environment you are running, but the steps should be relatively close to the same. These steps will create a script that you can run from the command line and also a desktop launcher that can be launched by clicking on it. Either way, it is best to have it asking for a password before the reboot happens.
First thing is to create a script that will contain the commands based from my other answer here using grub-reboot
as it sets the default boot entry for GRUB, for the next boot only. The reason for this is so there is no editing of the /etc/default/grub
file or the /boot/grub/grub.cfg
file.
I called my script win_reboot.bsh
, but before adding the contents to the script, run sudo os-prober
to get a more precise name of the Windows 10 just in case there are multiple entries like could be found in OEM systems with recovery, etc.
I don't use GPT or run on an OEM system so I only have one entry.
terrance@terrance-ubuntu:~$ sudo os-prober
/dev/sdh1:Windows 10 (loader):Windows:chain
Take note of the Windows name between the colons :
. We are going to use the Windows 10 (loader)
. awk
will actually have a problem with special characters like ()/
so we will have to escape those with a like
Windows 10 (loader)
. We are going to use this line because it will be more precise if there are multiple entries in the os-prober
that is run before grub-update
writes a new /boot/grub/grub.cfg
file.
For this, we are also going to use the pkexec
command which should already be installed. gksu is deprecated.
Script contents:
#!/bin/bash
if [ $UID != 0 ]; then
echo "Please run as 'sudo $0'"
exit 1
fi
grub-reboot "$(awk -F"'" '/Windows 10 (loader)/ print $2' /boot/grub/grub.cfg)"
reboot
That script will search through the grub.cfg
file and get the full name of the Windows 10 (loader)
boot. I did the line to handle changes if a grub-update
is performed in the future and changes the name of that line. The reason for this is that if you add a hard drive or leave a USB drive in the system that is not bootable during a boot up, the drive designation can change. You could see a line that reads like Windows 10 (loader) (on /dev/sdh1)
then on another grub-update
it changes to Windows 10 (loader) (on /dev/sdg1)
. Good thing that these entries actually rely on the UUID
of the partition and not the name in the grub entry.
Next, make the script executable:
sudo chmod +x win_reboot.bsh
Now if you run it from the command line without sudo it should look like this:
terrance@terrance-ubuntu:~/scripts$ ./win_reboot.bsh
Please run as 'sudo ./win_reboot.bsh'
Create a shortcut to the new script. I hope that when you right-click on your desktop that Create Launcher
is one of the options. I am running Xfce4
as my desktop. I guess you could create a launcher based on the comment posted by Andrew Shum as it should still work as long as it points to the win_reboot.bsh script.
Edit: I changed the launcher here based on the comments I received below. sudo -H
does not work in the command of a launcher, unless you have set the option to Run in Terminal. One other thing to note here that this launcher is calling a CLI script and not a GUI application.
You can create a file in your ~/Desktop
folder named Boot to Windows 10.desktop
and add the following to it:
[Desktop Entry]
Version=1.0
Type=Application
Name=Boot to Windows 10
Comment=Reboot System to Windows 10
Exec=pkexec /home/terrance/scripts/win_reboot.bsh
Icon=web-microsoft
Path=
Terminal=false
StartupNotify=false
Remember to change the Exec=
line to match your file location.
Then when you launch the shortcut you will see something similar to enter your password as the Super User:
Hope this helps!
NOTE: This answer has been a work in progress.
This can be done. I am not sure what Desktop Environment you are running, but the steps should be relatively close to the same. These steps will create a script that you can run from the command line and also a desktop launcher that can be launched by clicking on it. Either way, it is best to have it asking for a password before the reboot happens.
First thing is to create a script that will contain the commands based from my other answer here using grub-reboot
as it sets the default boot entry for GRUB, for the next boot only. The reason for this is so there is no editing of the /etc/default/grub
file or the /boot/grub/grub.cfg
file.
I called my script win_reboot.bsh
, but before adding the contents to the script, run sudo os-prober
to get a more precise name of the Windows 10 just in case there are multiple entries like could be found in OEM systems with recovery, etc.
I don't use GPT or run on an OEM system so I only have one entry.
terrance@terrance-ubuntu:~$ sudo os-prober
/dev/sdh1:Windows 10 (loader):Windows:chain
Take note of the Windows name between the colons :
. We are going to use the Windows 10 (loader)
. awk
will actually have a problem with special characters like ()/
so we will have to escape those with a like
Windows 10 (loader)
. We are going to use this line because it will be more precise if there are multiple entries in the os-prober
that is run before grub-update
writes a new /boot/grub/grub.cfg
file.
For this, we are also going to use the pkexec
command which should already be installed. gksu is deprecated.
Script contents:
#!/bin/bash
if [ $UID != 0 ]; then
echo "Please run as 'sudo $0'"
exit 1
fi
grub-reboot "$(awk -F"'" '/Windows 10 (loader)/ print $2' /boot/grub/grub.cfg)"
reboot
That script will search through the grub.cfg
file and get the full name of the Windows 10 (loader)
boot. I did the line to handle changes if a grub-update
is performed in the future and changes the name of that line. The reason for this is that if you add a hard drive or leave a USB drive in the system that is not bootable during a boot up, the drive designation can change. You could see a line that reads like Windows 10 (loader) (on /dev/sdh1)
then on another grub-update
it changes to Windows 10 (loader) (on /dev/sdg1)
. Good thing that these entries actually rely on the UUID
of the partition and not the name in the grub entry.
Next, make the script executable:
sudo chmod +x win_reboot.bsh
Now if you run it from the command line without sudo it should look like this:
terrance@terrance-ubuntu:~/scripts$ ./win_reboot.bsh
Please run as 'sudo ./win_reboot.bsh'
Create a shortcut to the new script. I hope that when you right-click on your desktop that Create Launcher
is one of the options. I am running Xfce4
as my desktop. I guess you could create a launcher based on the comment posted by Andrew Shum as it should still work as long as it points to the win_reboot.bsh script.
Edit: I changed the launcher here based on the comments I received below. sudo -H
does not work in the command of a launcher, unless you have set the option to Run in Terminal. One other thing to note here that this launcher is calling a CLI script and not a GUI application.
You can create a file in your ~/Desktop
folder named Boot to Windows 10.desktop
and add the following to it:
[Desktop Entry]
Version=1.0
Type=Application
Name=Boot to Windows 10
Comment=Reboot System to Windows 10
Exec=pkexec /home/terrance/scripts/win_reboot.bsh
Icon=web-microsoft
Path=
Terminal=false
StartupNotify=false
Remember to change the Exec=
line to match your file location.
Then when you launch the shortcut you will see something similar to enter your password as the Super User:
Hope this helps!
edited Mar 22 at 4:55
answered Mar 19 at 23:54
![](https://i.stack.imgur.com/1hPwN.jpg?s=32&g=1)
![](https://i.stack.imgur.com/1hPwN.jpg?s=32&g=1)
Terrance
17.3k23885
17.3k23885
It probably won't be an issue for Largobone, but it seems like that particular solution would run into trouble if there are multiple entries for a "Windows 10". For instance, my computer at work was setup with Windows 7 by IT and somehow ended up with 3 (maybe 4) separate images; all detected by Grub yet only one is actually setup. Also, if one is going to make a launcher, shouldn't "gksudo" be used instead?
â Andrew Shum
Mar 21 at 9:37
@AndrewShum Updated based on your comment.
â Terrance
Mar 21 at 13:46
I thought gksudo was depreciated for launching gui apps. And you should not just use sudo either, current recommended method issudo -H
# which keeps /home as location of files. see askubuntu.com/questions/11760/â¦
â oldfred
Mar 21 at 13:54
@oldfred You are right. However, this is only a call to a script not a GUI application. I need to change my image and edit this answer one more time to usepkexec
instead. Thesudo -H
at this point is moot because I have tested both ways and they work fine.
â Terrance
Mar 21 at 14:15
@oldfred Thanks for sharing that information. Is it the same withsu
vsgksu
and does it necessarily impact older OSs? The specific post that mentioned it was specifically about 17 and up.
â Andrew Shum
Mar 21 at 17:45
 |Â
show 1 more comment
It probably won't be an issue for Largobone, but it seems like that particular solution would run into trouble if there are multiple entries for a "Windows 10". For instance, my computer at work was setup with Windows 7 by IT and somehow ended up with 3 (maybe 4) separate images; all detected by Grub yet only one is actually setup. Also, if one is going to make a launcher, shouldn't "gksudo" be used instead?
â Andrew Shum
Mar 21 at 9:37
@AndrewShum Updated based on your comment.
â Terrance
Mar 21 at 13:46
I thought gksudo was depreciated for launching gui apps. And you should not just use sudo either, current recommended method issudo -H
# which keeps /home as location of files. see askubuntu.com/questions/11760/â¦
â oldfred
Mar 21 at 13:54
@oldfred You are right. However, this is only a call to a script not a GUI application. I need to change my image and edit this answer one more time to usepkexec
instead. Thesudo -H
at this point is moot because I have tested both ways and they work fine.
â Terrance
Mar 21 at 14:15
@oldfred Thanks for sharing that information. Is it the same withsu
vsgksu
and does it necessarily impact older OSs? The specific post that mentioned it was specifically about 17 and up.
â Andrew Shum
Mar 21 at 17:45
It probably won't be an issue for Largobone, but it seems like that particular solution would run into trouble if there are multiple entries for a "Windows 10". For instance, my computer at work was setup with Windows 7 by IT and somehow ended up with 3 (maybe 4) separate images; all detected by Grub yet only one is actually setup. Also, if one is going to make a launcher, shouldn't "gksudo" be used instead?
â Andrew Shum
Mar 21 at 9:37
It probably won't be an issue for Largobone, but it seems like that particular solution would run into trouble if there are multiple entries for a "Windows 10". For instance, my computer at work was setup with Windows 7 by IT and somehow ended up with 3 (maybe 4) separate images; all detected by Grub yet only one is actually setup. Also, if one is going to make a launcher, shouldn't "gksudo" be used instead?
â Andrew Shum
Mar 21 at 9:37
@AndrewShum Updated based on your comment.
â Terrance
Mar 21 at 13:46
@AndrewShum Updated based on your comment.
â Terrance
Mar 21 at 13:46
I thought gksudo was depreciated for launching gui apps. And you should not just use sudo either, current recommended method is
sudo -H
# which keeps /home as location of files. see askubuntu.com/questions/11760/â¦â oldfred
Mar 21 at 13:54
I thought gksudo was depreciated for launching gui apps. And you should not just use sudo either, current recommended method is
sudo -H
# which keeps /home as location of files. see askubuntu.com/questions/11760/â¦â oldfred
Mar 21 at 13:54
@oldfred You are right. However, this is only a call to a script not a GUI application. I need to change my image and edit this answer one more time to use
pkexec
instead. The sudo -H
at this point is moot because I have tested both ways and they work fine.â Terrance
Mar 21 at 14:15
@oldfred You are right. However, this is only a call to a script not a GUI application. I need to change my image and edit this answer one more time to use
pkexec
instead. The sudo -H
at this point is moot because I have tested both ways and they work fine.â Terrance
Mar 21 at 14:15
@oldfred Thanks for sharing that information. Is it the same with
su
vs gksu
and does it necessarily impact older OSs? The specific post that mentioned it was specifically about 17 and up.â Andrew Shum
Mar 21 at 17:45
@oldfred Thanks for sharing that information. Is it the same with
su
vs gksu
and does it necessarily impact older OSs? The specific post that mentioned it was specifically about 17 and up.â Andrew Shum
Mar 21 at 17:45
 |Â
show 1 more comment
2
Logout and reboot is simple. Just write a script with the
reboot
command. The trick is making GRUB boot another OS next time. This is explained here and especially here.â PerlDuck
Mar 19 at 17:12
1
Maybe this might help? askubuntu.com/a/859530/231142
â Terrance
Mar 19 at 17:20
1
@Terrance, your solution is a really great and simple one. It doesn't even require fiddling around with the /etc/default/grub file.
â PerlDuck
Mar 19 at 17:25
If you make a bash script to do what @Terrance suggested (which should only need two lines; I have done it before), you might be able to use a launcher to run it.
â Andrew Shum
Mar 19 at 19:06
Just found this which should help with being able to use a launcher.
â Andrew Shum
Mar 19 at 19:30