windows设置脚本
- 放入:
win+r输入shell:startup再按回车键
的目录中1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| wslname = "Ubuntu-20.04" wslport = "80" winport = "80"
If WScript.Arguments.Length = 0 Then CreateObject("Shell.Application").ShellExecute "wscript.exe" _ , """" & WScript.ScriptFullName & """ RunAsAdministrator", , "runas", 1 WScript.Quit End if set fso = CreateObject("Scripting.FileSystemObject") set objShell = CreateObject("WScript.Shell") writeip = objShell.Run("cmd /c ""wsl -d "+wslname+" -u root hostname -I"">C:\Windows\Temp\wslip.tmp",0,True) set f = fso.OpenTextFile("C:\Windows\Temp\wslip.tmp", 1) wslip = f.ReadAll() f.Close() command = "cmd /c ""netsh interface portproxy add v4tov4 listenport="+winport+" listenaddress=0.0.0.0 connectport="+wslport+" connectaddress="+wslip forwarding = objShell.Run(command,0,True) fso.deleteFile("C:\Windows\Temp\wslip.tmp")
|
放行windows防火墙