每次开机都要手动启动Ubuntu子系统,然后再去启动子系统内的PHP环境;很是麻烦,所以写了一个快速启动的bat脚本;
输入命令执行不同的脚本:
1、启动Ubuntu子系统|启动SSH服务|启动宝塔面板服务|启动MySql服务|启动Redis服务|获取宝塔面板信息
2、关闭Ubuntu子系统
3、重置Navicat Premium 16试用时间


Win环境工具脚本:
@echo off
title Ubuntu-20.04 By:barry
:home
echo.
echo ===============WinPHP环境工具==================
echo (1) 启动Ubuntu-20.04 (2) 停止Ubuntu-20.04
echo (3) Navicat Premium 16 Reset
echo ===============================================
set command=
set /p command=请输入命令编号:
if /I "%command%"=="1" ( goto :start_ubuntu_2004 ) ^
else if /I "%command%"=="2" ( goto :stop_ubuntu_2004 ) ^
else if /I "%command%"=="3" ( goto :navicat_premium_16_reset ) ^
else (
echo 输入有误,请按任意键重新输入!&& pause > nul && goto home
)
:end
:start_ubuntu_2004
::启动子系统
net start LxssManager
timeout /t 1 /nobreak
echo.
::SSH
echo 启动SSH服务...
wsl -u root -d Ubuntu-20.04 service ssh start
echo.
::宝塔
echo 启动BT服务...
wsl -u root -d Ubuntu-20.04 /etc/init.d/bt start
echo.
::MySql
echo 启动MySql服务...
wsl -u root -d Ubuntu-20.04 /etc/init.d/mysqld restart
echo.
::Redis
echo 启动Redis服务...
wsl -u root -d Ubuntu-20.04 /etc/init.d/redis start
echo.
echo 获取宝塔面板信息...
wsl -u root -d Ubuntu-20.04 /etc/init.d/bt default
echo.
pause && goto home
:end
:stop_ubuntu_2004
::关闭子系统
net stop LxssManager
pause && goto home
:end
:navicat_premium_16_reset
::重置Navicat Premium 16试用期限
echo Delete HKEY_CURRENT_USER\Software\PremiumSoft\NavicatPremium\Registration[version and language]
for /f %%i in ('"REG QUERY "HKEY_CURRENT_USER\Software\PremiumSoft\NavicatPremium" /s | findstr /L Registration"') do (
reg delete %%i /va /f
)
echo.
echo Delete Info folder under HKEY_CURRENT_USER\Software\Classes\CLSID
for /f %%i in ('"REG QUERY "HKEY_CURRENT_USER\Software\Classes\CLSID" /s | findstr /E Info"') do (
reg delete %%i /va /f
)
echo.
pause && goto home
:end转载请注明本文标题和链接:《 Win10快速启动Ubuntu子系统及PHP环境脚本 》



![[OK]](/data/assets/emotion/images/face/i_f50.gif)
你好站长,小小参谋网已经更换域名了,麻烦您有时间调整一下,谢谢原域名zzzx.org 新域名eejj.net祝老朋友您生活愉快,身体健康