1. 程式人生 > >BAT批處理文件

BAT批處理文件

需要 輸入密碼 意思 ssp etl pan 延遲 dex NPU

pgp 在做解密和加密的時候,命令行的方式總是需要手動輸入密碼和指定ID,比較繁瑣,所以寫了一個自動腳本。
比較有意思的地方是:
setlocal enabledelayedexpansion 變量延遲和!變量!的使用。同樣的方式可以讀入文本文件中不同行的內容來賦值變量

@echo off

:: todo
setlocal enabledelayedexpansion
set /a j=0
for /f "tokens=1-3 delims=" %%i in (ps.txt) do (
set /a j+=1
rem set /a j+=1
rem echo !j!
rem echo %%i
if !j!==1 set ps=%%i

rem if !j!==2 set txt=%%i

)
rem echo %ps%
rem echo %txt%
set inputfile=%1%
echo -----------------------------------------------------------
echo Decrypt the pgp file from WideVine portal - %inputfile%
echo -----------------------------------------------------------
echo;
set outputfile=%inputfile:~0,-28%xml
rem echo Output file - %outputfile%

gpg --passphrase %ps% --decrypt %inputfile% > %outputfile%
echo -----------------------------------------------------------
echo Decrypt the pgp file successfully.
echo Encrypt the %outputfile% with customer key
echo -----------------------------------------------------------
echo;

gpg -r widevine_keys -e %outputfile%

rm %outputfile%

BAT批處理文件