@echo off chcp 65001 >nul echo ======================================== echo ThCardReader x86 Release Package Script echo ======================================== echo. :: 设置变量 set SOURCE_DIR=E:\huaihaiProject\ThCardReader\mhCardReader\ThCardReader\bin\x86\Release :: 获取英文格式的日期时间 for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" set "TIMESTAMP=%YYYY%%MM%%DD%_%HH%%Min%%Sec%" set PACKAGE_NAME=ThCardReader_x86_Release_%TIMESTAMP% set TEMP_DIR=%cd%\temp_%PACKAGE_NAME% echo Source Directory: %SOURCE_DIR% echo Package Name: %PACKAGE_NAME% echo Temp Directory: %TEMP_DIR% echo. :: 检查源目录是否存在 if not exist "%SOURCE_DIR%" ( echo [ERROR] Source directory does not exist: %SOURCE_DIR% echo Please make sure the path is correct and the project has been built. pause exit /b 1 ) :: 检查源目录是否有文件 dir "%SOURCE_DIR%" >nul 2>&1 if errorlevel 1 ( echo [ERROR] Cannot access source directory or directory is empty. pause exit /b 1 ) echo [INFO] Checking source directory contents... dir "%SOURCE_DIR%" /b | find /c /v "" > temp_count.txt set /p FILE_COUNT=nul 2>&1 if exist "%TEMP_DIR%\jiangsu_config.txt" ( echo [SUCCESS] External config file copied successfully from project source. ) else ( echo [INFO] External config file not found, but program will use default configuration. echo [INFO] Program will work with default settings if external config is missing. ) ) else ( echo [SUCCESS] External config file found in Release directory. ) :: 验证外部配置文件的内容 echo [INFO] Validating external config file... if exist "%TEMP_DIR%\jiangsu_config.txt" ( findstr /c:"IP=" "%TEMP_DIR%\jiangsu_config.txt" >nul if errorlevel 1 ( echo [WARNING] External config file may be incomplete, but program will use defaults. echo [WARNING] Missing config items will be replaced with default values. ) else ( echo [SUCCESS] External config file appears to be valid. ) ) else ( echo [INFO] No external config file found, program will use default configuration. ) :: 验证复制结果 echo [INFO] Verifying copied files... dir "%TEMP_DIR%" /b | find /c /v "" > temp_count2.txt set /p COPIED_COUNT=nul echo. :: 创建ZIP包 echo [INFO] Creating ZIP package... set ZIP_FILE=%PACKAGE_NAME%.zip :: 使用PowerShell创建ZIP(Windows 10+自带) powershell -Command "Compress-Archive -Path '%TEMP_DIR%\*' -DestinationPath '%ZIP_FILE%' -Force" if errorlevel 1 ( echo [ERROR] Failed to create ZIP package. echo Please make sure PowerShell is available and try again. pause goto cleanup ) :: 验证ZIP文件 if exist "%ZIP_FILE%" ( for %%f in ("%ZIP_FILE%") do ( echo [SUCCESS] Package created successfully! echo File: %ZIP_FILE% echo Size: %%~zf bytes echo Created: %%~tf ) echo. :: 显示ZIP内容统计(简化版本,兼容所有系统) echo [INFO] Package contents summary: echo Files: %COPIED_COUNT% for %%f in ("%ZIP_FILE%") do echo ZIP Size: %%~zf bytes ) else ( echo [ERROR] ZIP package was not created. ) :cleanup :: 清理临时目录 echo [INFO] Cleaning up temporary files... if exist "%TEMP_DIR%" ( rmdir /s /q "%TEMP_DIR%" echo [INFO] Temporary directory removed. ) echo. echo ======================================== echo Package operation completed! echo ======================================== echo. echo IMPORTANT NOTES: echo - Source files were NOT modified in any way echo - Package contains EXACT copy of x86\Release echo - Package name: %PACKAGE_NAME%.zip echo - All files preserved as-is with original timestamps echo. echo CRITICAL CONFIGURATION CHANGES: echo - Program PRIORITIZES external config file (jiangsu_config.txt) echo - If external config file is missing, program uses default configuration echo - If config items are missing, program uses default values echo - Users can modify jiangsu_config.txt after deployment echo - Program will work even without external config file echo. echo DEPLOYMENT NOTES: echo - Extract the ZIP file to any directory echo - Modify jiangsu_config.txt as needed for your environment echo - Run ThCardReader.exe echo - All configuration changes require only file editing, no recompilation echo - Program will work with default settings if config file is missing echo. pause