0

I have this vbs script that I've been using to run gnome-terminalfrom my Windows 10 Desktop. It executes the following commands in strArgs without showing terminal window that's executing the commands.

Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "wsl 'DISPLAY=:0 gnome-terminal"
oShell.Run strArgs, 0, false

However, the script works only if I execute DISPLAY=:0 gnome-terminal in my vanilla wsl terminal first. I'm not sure what its starting up in my processes that allows the script to work, but I really don't want to keep doing this every time I restart my computer.

0

Apparently adding the read command after gnome-terminal gets it to work. Now I don't need to enter the commands in a command window with every reboot to get the desktop shortcut to work.

Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "wsl 'DISPLAY=:0 gnome-terminal;read"
oShell.Run strArgs, 0, false
0

The issue is that DBus needs to be launched first. This batch script works for me, and also checks to make sure the VcXsrv is running:

tasklist /FI "IMAGENAME eq vcxsrv.exe" 2>NUL | find /I /N "vcxsrv.exe">NUL
if "%ERRORLEVEL%"=="0" echo X server is running
if not "%ERRORLEVEL%"=="0" start "" "C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -dpi auto
ubuntu run "sh -ic 'if [ -z \"$(pidof dbus-launch)\" ]; then export DISPLAY=127.0.0.1:0.0; dbus-launch --exit-with-x11; fi;'"
ubuntu run "DISPLAY=:0 gnome-terminal --working-directory=/home/kevin; sleep 1"

Of course edit the directories, and change the command from ubuntu if you're using something else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.