-
-
Save tautomer/1644ceff1a42cb57f66faba39067c63e to your computer and use it in GitHub Desktop.
VBS Script to Check if vcxsrv.exe Is Running and Launch Terminator through WSL 2
This file contains hidden or 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
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 | |
Set objShell = Wscript.CreateObject("Wscript.Shell") | |
If NOT IsProcessRunning("vcxsrv.exe") Then | |
objShell.Popup "We will launch vcxsrv.exe first!", 1, "VcXSrv is not running", 64 | |
objShell.Exec("C:\Program Files\VcXsrv\vcxsrv.exe :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl") | |
End If | |
args = "-c " & """DISPLAY=$(cat /etc/resolv.conf | grep name | cut -d' ' -f2):0 terminator""" | |
WScript.CreateObject("Shell.Application").ShellExecute "bash", args, "", "open", 0 |
Update for WSL 2, but I'm not sure if it's compatible with WSL 1 or not. Gonna test it out tonight.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You don't have to launch vcxsrv.exe manually with this script.
A message box will pop up and auto close in 1s if vcxsrv is not running. You can get rid of this by commenting out the
objShell.Popup
line.