-
-
Save ropnop/10800fb5066bd5144d9aaad55a8a4d18 to your computer and use it in GitHub Desktop.
args = "-c" & " -l " & """DISPLAY=:0 terminator""" | |
WScript.CreateObject("Shell.Application").ShellExecute "bash", args, "", "open", 0 |
@chazakki Are you asking about starting subl from within WSL using a similar script? You'll probably only need to change the call to WScript.CreateObject(...)...
, but I couldn't say what the exact solution is. I bet that there are other examples out there that are closer to what you're looking for.
Additionally, I haven't used subl in years but VSCode runs natively in WSL using a proprietary VSCode server solution. subl may offer something similar, but I haven't looked into this myself.
Automatically retrieve the ip address related to your WSL2 adapter using adapter name in the function GetIpFromAdapter
, in VBS :
' 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
StrIP=GetIpFromAdapter("Hyper-V Virtual Ethernet Adapter #2")
shell.ShellExecute "bash", "-c -l ""DISPLAY="&StrIP &":0 terminator""", "", "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
Function GetIpFromAdapter( adapterName )
dim NIC1, Nic
Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
For Each Nic in NIC1
if Nic.IPEnabled And Nic.Description=adapterName then
GetIpFromAdapter = Nic.IPAddress(0)
End if
Next
End Function
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?
Giant PITA!
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
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
Thanks @fahri314
how do I make same kind of .vbs to run subl?