@echo OFF 

if not "%~1"=="p" start /min cmd.exe /c %0 p&exit

echo  !!!!!!!!准备安装PMS插件相关程序!!!!!!!!!!
echo  _________________________________________
echo  _________________________________________
echo  .
echo  !!!!!!!!请勿关闭此窗口!!!!!!!!!!
echo  !!!!!!!!请勿关闭此窗口!!!!!!!!!!
echo  .
echo  !!!!!!!!!!!!!请耐心等待 3 分钟左右!!!!!!!!!!!!!!
echo  !!!!!!!!程序安装完成后，此窗口会自动关闭!!!!!!!!!!!!
echo  .
echo  !!!!!!!!请勿关闭此窗口!!!!!!!!!!
echo  !!!!!!!!请勿关闭此窗口!!!!!!!!!!
echo  .
echo  _________________________________________
echo  _________________________________________
echo  ................

rem #1、进入当前BAT脚本所在的目录；
set curdir=%~dp0
cd /d %curdir%

rem #1.1、判断当前进程是存在，存在则kill；
tasklist>C:\FMtasklist.txt
find "PmsPlugin.exe" C:\FMtasklist.txt&&taskkill /f /im "PmsPlugin.exe"

rem 2、判断指定的两个目录是否存在，存在则备份；
if exist c:\Freemud\PmsPlugin (
   echo "已经存在目录: PmsPlugin; 备份原始，更新当前包"
   move c:\Freemud\PmsPlugin  c:\Freemud\PmsPlugin_bak
   md  c:\Freemud\PmsPlugin
)

ping -n 10 127.1>nul

rem #3、拷贝安装包目录下的两个程序包到指定的C盘目录；
xcopy  /s/e/y/i/f  PmsPlugin  c:\Freemud\PmsPlugin        
echo "拷贝程序包到目标目录完成"
ping -n 10 127.1>nul

rem 3、将PmsPlugin目录下的开机启动外卖插件程序的bat脚本拷贝到系统启动项中；
copy c:\Freemud\PmsPlugin\StartPmsPluginProgram.bat  c:\Users\Administrator\AppData\Roaming\Microsoft\Windows\"Start Menu"\Programs\Startup\
rem copy c:\Freemud\PmsPlugin\StartPmsPluginProgram.bat  C:\Freemud\"zwy abc"\
echo "拷贝开机自启动脚本 StartPmsPluginProgram.bat 到指定目录完成"
ping -n 10 127.1>nul

rem 4、程序安装完成后，启动插件程序；
IF EXIST C:\Freemud\PmsPlugin\PmsPlugin.exe    start "" "C:\Freemud\PmsPlugin\PmsPlugin.exe"    

echo  !!!!!!!!启动程序完成!!!!!!!!
