標籤:
背景:以下指令碼使用了匯出檔案清單、移動檔案、複製檔案、report 系統資訊、分段執行的功能
主要針對在從事於Easeware公司中,對軟體Bug中,所需檔案的提取。
程式碼片段說明:
cls
ver | find "5.1." > NUL && goto win_xp
:win_xp
## 判斷出使用者作業系統為windows xp 將執行:win_xp下面的代碼塊,其他代碼不執行。
dir /B /S > fileList.txt
## 擷取目前的目錄下所有的檔案夾名、檔案名稱列表,並匯出到fileList.txt檔案中
rd /s /q DriverEasy
## 刪除目前的目錄下的DriverEasy檔案夾
msinfo32 /report %userprofile%\Desktop\info.txt
## 匯出使用者電腦裝置資訊,並將檔案儲存到案頭
完整代碼:
@echo offcls ver | find "5.1." > NUL && goto win_xp ver | find "5.1." > NUL && goto winvistaver | find "6.1." > NUL && goto win7 ver | find "6.2." > NUL && goto win8 ver | find "6.3." > NUL && goto win8.1 :win_xp @echo The current system is:WinXP cd "%AppData%\Easeware\DriverEasy"dir /B /S > fileList.txtmove fileList.txt "%userprofile%\Desktop"cd "%AppData%\Easeware\DriverEasy\drivers"copy DownloadDrivers.data "%userprofile%\Desktop"cd C:\Program Files\Common Files\Microsoft Shared\MSInfomsinfo32.exe /report "%userprofile%\Desktop\info.txt"@echo ---------------------------------------- goto end :winvista @echo The current system is:winvista cd %userprofile%\AppData\Roaming\Easeware\DriverEasydir /B /S > fileList.txtmove fileList.txt %userprofile%\Desktopcd %userprofile%\AppData\Roaming\Easeware\DriverEasy\driverscopy DownloadDrivers.data %userprofile%\Desktopmsinfo32 /report %userprofile%\Desktop\info.txt@echo ---------------------------------------- goto end :win7 @echo The current system is:win7 cd %userprofile%\AppData\Roaming\Easeware\DriverEasydir /B /S > fileList.txtmove fileList.txt %userprofile%\Desktopcd %userprofile%\AppData\Roaming\Easeware\DriverEasy\driverscopy DownloadDrivers.data %userprofile%\Desktopmsinfo32 /report %userprofile%\Desktop\info.txt@echo ---------------------------------------- goto end :win8 @echo The current system is:win8 cd %userprofile%\AppData\Roaming\Easeware\DriverEasydir /B /S > fileList.txtmove fileList.txt %userprofile%\Desktopcd %userprofile%\AppData\Roaming\Easeware\DriverEasy\driverscopy DownloadDrivers.data %userprofile%\Desktopmsinfo32 /report %userprofile%\Desktop\info.txt@echo ---------------------------------------- goto end :win8.1 @echo The current system is:win8.1 cd %userprofile%\AppData\Roaming\Easeware\DriverEasydir /B /S > fileList.txtmove fileList.txt %userprofile%\Desktopcd %userprofile%\AppData\Roaming\Easeware\DriverEasy\driverscopy DownloadDrivers.data %userprofile%\Desktopmsinfo32 /report %userprofile%\Desktop\info.txt@echo ---------------------------------------- goto end @echo Can not get the current operating system version @echo ---------------------------------------- :end pause
Code
bat 指令碼處理windows 檔案