安装 jdk, mysql 和 开发的应用并 设置为服务自启动的脚本

发布时间 2024-01-09 10:43:23作者: 涵旭

安装的 bat

install.bat

内容如下:

@echo off
title installing.... not close
color 0a
echo jdk 环境变量
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v JAVA_HOME /t REG_EXPAND_SZ /d "%cd%\jdk1.8.0_191" /f
reg add "HKEY_CURRENT_USER\Environment" /v JAVA_HOME /t REG_EXPAND_SZ /d "%cd%\jdk1.8.0_191" /f

echo 系统环境变量
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v "PATH" /d "%PATH%;%cd%\jdk1.8.0_191\bin;" /f
reg add "HKEY_CURRENT_USER\Environment" /v "PATH" /d "%PATH%;%cd%\jdk1.8.0_191\bin;" /f

echo 启动mysql并更新密码
"%cd%\mysql-5.7.24\bin\mysqld.exe" --initialize-insecure --console --explicit_defaults_for_timestamp

"%cd%\mysql-5.7.24\bin\mysqld.exe" install
net start MySql
sc config MySql start=auto

ping -n 5 127.1>nul

echo "install mysql"
"%cd%\mysql-5.7.24\bin\mysql.exe" -uroot --skip-password -e "CREATE DATABASE IF NOT EXISTS  my_db"
"%cd%\mysql-5.7.24\bin\mysql.exe" -uroot --skip-password sky_report <"%cd%\mysql-5.7.24\my_db.sql"
"%cd%\mysql-5.7.24\bin\mysql.exe" -uroot --skip-password <"%cd%\mysql-5.7.24\create_user.sql" --default-character-set=utf8
net stop MySql
net start MySql

ping -n 5 127.1>nul
%cd%\server\nssm install myService %cd%\jdk1.8.0_191\bin\java.exe
%cd%\server\nssm set myService AppParameters -jar skyReport-0.0.1-SNAPSHOT.jar -Dspring.config.location=application.properties
%cd%\server\nssm set myService AppDirectory %cd%\server
%cd%\server\nssm set myService AppStdout %cd%\server\log\log.log
%cd%\server\nssm set myService AppStderr %cd%\server\log\err.log
%cd%\server\nssm set myService AppStopMethodSkip 6
%cd%\server\nssm set myService AppStopMethodConsole 1000
%cd%\server\nssm set myService AppThrottle 5000
%cd%\server\nssm set myService AppRotateFiles 1
%cd%\server\nssm set myService AppRotateOnline 0
%cd%\server\nssm set myService AppRotateSeconds 86400
%cd%\server\nssm set myService AppRotateBytes 104857
%cd%\server\nssm start myService

exit

卸载的批处理

unistall.bat 

内容

@echo off
title abc系统正在卸载中,请不要手动关闭
color 0a
echo 删除环境变量
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v JAVA_HOME /f
reg delete "HKEY_CURRENT_USER\Environment" /v JAVA_HOME /f
;cd .\tomcat6.0\bin
echo 停止并删除mysql
net stop MySQL
sc delete MySQL

net stop skyReportService
sc delete skyReportService
exit

---------------------------------------------

加载的批处理

 loading.bat 

@echo off
echo pause;