Setup.bat
REM *************************************************
REM *************************************************
REM 設定批處理文件存放的位置
cd C:/Program Files
md Backup
cd C:/Program Files/Backup
REM 建立批处理文件,该文件用于每次启动计算机的自动执行档
echo @ECHO OFF>Start.bat
echo title 群邦電子(蘇州)有限公司>>Start.bat
echo REM --------------- CHECK CONNECTION --------------->>Start.bat
echo ping bu2-db>>Start.bat
echo if errorlevel 1 goto local>>Start.bat
echo goto server>>Start.bat
echo. >>Start.bat
echo REM --------------- SERVER CONNECTION --------------->>Start.bat
echo :server>>Start.bat
echo net use V: /delete>>Start.bat
echo net use V: //192.168.101.1/run/Start testuser /USER:operator>>Start.bat
echo Call V:/Renew.bat>>Start.bat
echo goto end>>Start.bat
echo. >>Start.bat
echo REM --------------- LOCAL CONNECTION --------------->>Start.bat
echo :local>>Start.bat
echo if exist "%ProgramFiles%"/Backup/Test/*.* xcopy "%ProgramFiles%"/Backup/Test/*.* D:/PCL/Test/*.* /S/R/Y>>Start.bat
echo goto end>>Start.bat
echo. >>Start.bat
echo REM --------------- END --------------->>Start.bat
echo goto end>>Start.bat
echo :end>>Start.bat
REM 建立注册表文件,并将该注册表文件内容导入到注册表中,然后删除该注册表文件(给系统添加启动项)
echo Windows Registry Editor Version 5.00>Temp.reg
echo [HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run]>>Temp.reg
echo "AutoStart"="C://Program Files//Backup//Start.bat">>Temp.reg
regedit Temp.reg
if errorlevel 1 goto Fail
goto Succeed
REM 文件安裝失敗
:Fail
del Temp.reg
del Start.bat
REM 重新设定CMD执行目录
D:
cls
echo The document installs the failure!
goto End
REM 文件安裝成功
:Succeed
del Temp.reg
REM 重新设定CMD执行目录
D:
cls
echo The document installs the success!
goto End
:End
pause
PLS create Renew.bat t
Renew.bat
@ECHO ON
cls
title 群邦電子(蘇州)有限公司
REM 如果存在Test文件夾,則進行更新
if exist V:/Test goto Exist
goto End
REM 開始更新所有子目錄及文件(同时备份)
:Exist
title 正在進行軟體更新中,請稍後...
CD "%ProgramFiles%/Backup
if not exist Test MD Test
xcopy V:/Test/*.* Test/*.* /S/R/Y
xcopy V:/Test/*.* D:/PCL/Test/*.* /S/R/Y
REM 開始創建桌面快捷方式
REM 判斷需要建立捷徑的源文件是否存在
if not exist D:/PCL/Test/TestProgram/"Testdata Upload and Move for OC48DB V2.1.exe" cls & goto End
echo Dim WshShell,Shortcut>>tmp.vbs
echo Dim path,fso>>tmp.vbs
REM 指定要建立捷徑的源文件路徑 path (所有的路徑兩端必需加上雙引號 " " )
echo path="D:/PCL/Test/TestProgram/Testdata Upload and Move for OC48DB V2.1.exe">>tmp.vbs
echo Set fso=CreateObject("Scripting.FileSystemObject")>>tmp.vbs
echo Set WshShell=WScript.CreateObject("WScript.Shell")>>tmp.vbs
REM 指定建立的捷徑存放的路徑。 (最後的 .lnk 擴展名不可缺少!)
echo Set Shortcut=WshShell.CreateShortCut("%USERPROFILE%/桌面/Testdata Upload and Move for OC48DB V2.1.lnk")>>tmp.vbs
echo Shortcut.TargetPath=path>>tmp.vbs
echo Shortcut.Save>>tmp.vbs
"%SystemRoot%/System32/WScript.exe" tmp.vbs
del tmp.vbs /s /q
goto End
:End