好吧,我对批处理还很陌生..我在编写解密批处理时仍在学习。无论如何,我想在命令处理时制作一个进度条,但这似乎是不可能的(至少对我来说)。这是我的代码:
echo [41m The Password Is : wave4tech[0m
echo.
echo Please Enter The Password :
rem **all dlls or modules are in sub folder named data just to make everything clear
cd "data"
'some decryption commands' wave4tech.net >nul 2>&1 && echo Your Files Decrypted Successfully || echo [101;93m You Entered Wrong Password, Please Try Again![0m
7z x %UserProfile%\Desktop\archive -o"%UserProfile%\Desktop\" >nul 2>&1
del "%UserProfile%\Desktop\archive" >nul 2>&1
pause
一切都按预期进行!唯一的问题是,用户输入密码后,需要花费大量时间来解密文件,因此用户可能会关闭批处理,我只想通知他正在发生一个动作,即使它是简单的动画点,如(......)但如果它是实时的,它会更好(不仅仅是随机定时动画,因此即使在过程完成后,它仍会继续动画几分钟)。提前谢谢您。
答案1
经过我们的评论交换,似乎您想要的脚本如下:
:: -- Lets make sure our commands are not printed on the screen. Makes things cleaner.
@echo off
:: -- Set temp file location
set tmpfile=%TEMP%\pgppasswd.dat
:: -- Write password to tmpfile
echo wave4tech>%tmpfile%
echo. >>%tmpfile%
:: -- User has to wait for pgp, lets display.
echo Please wait while we decrypt your file.
:: **all dlls or modules are in sub folder named data just to make everything clear
:: -- moving to data directory.
cd "data"
:: -- lets validate the file and see if decrypts
gpg.exe --output %UserProfile%\Desktop\archive --batch --passphrase-fd 0 --decrypt wave4tech.net <%tmpfile% >nul 2>&1 && echo Your Files Decrypted Successfully || echo [101;93m Password did not work for this file![0m
:: -- Print a wait notification:
echo "Please wait while archinving.
:: -- Running 7zip
7z x %UserProfile%\Desktop\archive -o"%UserProfile%\Desktop\" >nul 2>&1
:: -- Removing old stuff
del %tmpfile%
del "%UserProfile%\Desktop\archive" >nul 2>&1
:: -- print a we're done message on a clear screen.
cls
echo Process complete. Thank you for your time.
pause
该::
命令与 REM 相同,但看起来更清晰,并且使脚本更具可读性。