Last active
July 6, 2021 03:05
-
-
Save Tibalt/4644b234ef3c483f01f7594de06e7c00 to your computer and use it in GitHub Desktop.
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
Const WshRunning = 0 | |
Const WshFinished = 1 | |
Const WshFailed = 2 | |
dim WSLIP | |
WSLIP = "" | |
dim ret | |
ret = 1 | |
Set ObjFSO = CreateObject("Scripting.FileSystemObject") | |
Set objLog = objFSO.CreateTextFile("c:\rebootlog.txt") | |
Set ws = Wscript.CreateObject("Wscript.Shell") | |
do until ret = 0 | |
ret = ws.run ("route delete 224.0.0.0 ",0,true) | |
objLog.WriteLine Now() & " run route delete return ret value: " & ret | |
WScript.sleep 2000 | |
Loop | |
ret=1 | |
do until ret = 0 | |
'ret = ws.run ("wsl -d Ubuntu-18.04 -u root /etc/init.wsl",0,true) | |
ret = ws.run ("wsl -d Ubuntu-18.04 -u root ls",0,true) | |
objLog.WriteLine Now() & " run /etc/init.wsl return ret value: " & ret | |
WScript.sleep 2000 | |
Loop | |
ret=1 | |
cmd = "netsh interface ip show address ""vEthernet (WSL)"" |findstr ""IP"" " | |
do until ret = 0 | |
Set WshShell = CreateObject("WScript.Shell") | |
Set WshShellExec = WshShell.Exec("%comspec% /c " & cmd) | |
Do While WshShellExec.Status = WshRunning | |
WScript.Sleep 100 | |
Loop | |
Select Case WshShellExec.Status | |
Case WshFinished | |
WSLIP = WshShellExec.StdOut.ReadAll() | |
ret = 0 | |
Case WshFailed | |
ret = 1 | |
WSLIP = WshShellExec.StdErr.ReadAll() | |
End Select | |
objLog.WriteLine Now() & " before right: " & WSLIP | |
WSLIP = Replace(WSLIP, vbCr, "") | |
WSLIP = Replace(WSLIP, vbLf, "") | |
WSLIP = Right(WSLIP,16) | |
objLog.WriteLine Now() & " netsh get ip: " & WSLIP | |
WScript.sleep 2000 | |
Loop | |
ret=1 | |
do until ret = 0 | |
ret = ws.run ("route -p add 224.0.0.0 mask 240.0.0.0 " & WSLIP,0,true) | |
objLog.WriteLine Now() & " "" route -p add 224.0.0.0 mask 240.0.0.0 " & WSLIP & " "" " & "return: " &ret | |
WScript.sleep 2000 | |
Loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment