This batch script helps extract Product Keys from XML files within a designated folder. It utilizes a clever trick to remove the unnecessary 'ProductKey>' prefix from the output, resulting in a clean list of product keys./n/nOriginal Code:/n/n/n@echo off/nsetlocal enabledelayedexpansion/n/nset /'inputFolder=%~dp0/'/'/nset /'outputFile=output.txt/'/n/nfor %%F in (/'%inputFolder%/*.xml/') do (/n set /'xmlFile=%%~F/'/n for /f /'tokens=9 delims=<//' %%A in ('type /'!xmlFile!/' ^| findstr /i /c:/'<ProductKey>/'/') do (/n set /'productKey=%%A/'/n echo !productKey!>> /'%outputFile%/'/n )/n)/n/n echo /'Extraction complete./'/n/nendlocal/n/n/nIssue: The original script outputs Product Keys with the 'ProductKey>' prefix./n/nSolution:/n/nThe solution involves a simple modification to the echo command./n/nModified Code:/n/n/n@echo off/nsetlocal enabledelayedexpansion/n/nset /'inputFolder=%~dp0/'/'/nset /'outputFile=output.txt/'/n/nfor %%F in (/'%inputFolder%/*.xml/') do (/n set /'xmlFile=%%~F/'/n for /f /'tokens=9 delims=<//' %%A in ('type /'!xmlFile!/' ^| findstr /i /c:/'<ProductKey>/'/') do (/n set /'productKey=%%A/'/n echo !productKey:ProductKey>=!>> /'%outputFile%/'/n )/n)/n/n echo /'Extraction complete./'/n/nendlocal/n/n/nExplanation: The line echo !productKey:ProductKey>=!>> /'%outputFile%/' utilizes variable substitution to replace the 'ProductKey>' prefix with nothing, effectively removing it from the output./n/nOutput: After running the modified script, the output.txt file will contain a list of product keys without the 'ProductKey>' prefix, making the output more user-friendly and easier to use.

Batch Script to Extract Product Keys from XML Files

原文地址: https://www.cveoy.top/t/topic/pljq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录