Created
December 5, 2021 20:28
-
-
Save Kvieta1990/e978a58f6ad584c55b6b4bbe0d506d20 to your computer and use it in GitHub Desktop.
Windows shortcut for WSL Ubuntu apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set shell = CreateObject("WScript.Shell") | |
shell.CurrentDirectory = "E:\wsl_ubuntu_app" | |
shell.Run "cmd /c wsl-app-sudo-runner.bat gedit", 0, false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set shell = CreateObject("WScript.Shell") | |
shell.CurrentDirectory = "E:\wsl_ubuntu_app" | |
shell.Run "cmd /c wsl-app-runner.bat google-chrome-stable", 0, false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
for /f "tokens=3 delims=: " %%I in ('netsh interface IPv4 show addresses "vEthernet (WSL)" ^| findstr /C:"IP Address"') do set ip==%%I | |
set ipAddress=%ip:~1% | |
powershell.exe wsl "DISPLAY='%ipAddress%':0.0" %1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
for /f "tokens=3 delims=: " %%I in ('netsh interface IPv4 show addresses "vEthernet (WSL)" ^| findstr /C:"IP Address"') do set ip==%%I | |
set ipAddress=%ip:~1% | |
powershell.exe wsl "DISPLAY='%ipAddress%':0.0" sudo %1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With the setup in gist file, we don't have to put the VBScript and
.bat
files in the same directory, since the path to.bat
file to be executed in VBScript file is specified explicitly with full path.It is the VBScript files that are to be executed to launch the WSL Ubuntu Apps from Windows. So, we may need to further create shortcuts for those VBScript files. After creating shortcuts, we may find it is impossible to directly add those shortcuts to start menu. In this case, we may need to copy those shortcuts manually into Windows start menu -- we can create a folder (which can be with arbitrary name, e.g.,
Ubuntu Apps
) under the following folder and put those shortcuts in it,C:\Users\USER_NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Ubuntu Apps
A separate
.bat
file is also included here to execute some app withsudo
privilege. Particularly forgedit
, running withoutsudo
privilege for some reason cannot access settings to the program.