Skip to content

Instantly share code, notes, and snippets.

@ropnop
Created September 29, 2017 00:02
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save ropnop/10800fb5066bd5144d9aaad55a8a4d18 to your computer and use it in GitHub Desktop.
Save ropnop/10800fb5066bd5144d9aaad55a8a4d18 to your computer and use it in GitHub Desktop.
VBS Script to Launch Terminator through WSL
args = "-c" & " -l " & """DISPLAY=:0 terminator"""
WScript.CreateObject("Shell.Application").ShellExecute "bash", args, "", "open", 0
@fahri314
Copy link

fahri314 commented Dec 9, 2023

i used this script since last year. (Many thanks!) After i upgraded my windows to 11 it stopped working and i cant seem to find the problem. Do you have any experience with terminator wsl2 and windows 11?

Windows 11 does not need this script. When you install a program in wsl, you can find windows start menu with its name and you'll see with icon if exist

@fahri314
Copy link

fahri314 commented Dec 9, 2023

I added home directory changes and more reliable IP calculation:

' https://gist.github.com/ropnop/10800fb5066bd5144d9aaad55a8a4d18
set shell = WScript.CreateObject("Shell.Application")

if not IsProcessRunning("vcxsrv.exe") then
    shell.shellExecute "vcxsrv.exe", ":0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto", "C:\Program Files\VcXsrv\", "", 0
        WScript.Sleep 2000
end if

myCd = "~"
If WScript.Arguments.Length > 0 Then
    myCd = "'$(wslpath -u '" & WScript.Arguments(0) & "')'"
End If
args = "bash" & " -c ""cd " & myCd & " ;DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 terminator"""
shell.ShellExecute "C:\Windows\System32\wsl.exe", args, "", "open", 0

Function IsProcessRunning( strProcess )
    Dim Process, strObject
    IsProcessRunning = False
    strObject = "winmgmts://."
    For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
    If UCase( Process.name ) = UCase( strProcess ) Then
        IsProcessRunning = True
        Exit Function
    End If
    Next
End Function

@kamermans
Copy link

Thanks @fahri314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment