批量跳过作业(打印)时提示用户的消息框
Msgbox to prompt user if job (printing) is skip in batch
正如我在上一个问题中所建议的,每个线程 1 个问题。所以我在这里提出另一个问题。基本上我想提示用户今天将跳过打印,因为没有要打印的内容,然后用户将按确定,然后代码将继续关闭计算机。我想这样做是为了提醒用户今天的打印工作已经 运行.
所以我尝试了下面的一些代码,它似乎可以工作,但我不知道如何在我的主要代码中实现。
@echo off
Call :Msgbox
if "%errorlevel%"=="1" GOTO SHUTDOWN
exit /b
:Msgbox
echo wscript.quit MsgBox ("Printing skipped.. Press ok to shutdow the computer", 48, "Shutdown Computer") >"%temp%\input.vbs"
wscript //nologo "%temp%\input.vbs"
exit /b
:SHUTDOWN
echo "%SystemRoot%\System32\shutdown.exe -s -t 60"
PAUSE
这是我的主要代码的一部分,我想把代码放在上面。
如果 pdf 文件大小大于 9000 字节 > 今天打印 PDF > 然后转到关机
如果 pdf 文件大小小于 9000 字节 > 使用 msgbox 提示用户 > 用户按确定 > 跳过今天的打印 PDF > 然后转到关机
Rem ------------------------------------------------------------------------
Rem 4. Printing files with sizes over 9000 bytes
Set "_Exe1=%ProgramFiles(x86)%\Foxit Software\Foxit Reader\Foxit Reader.exe"
For %%A In ("%_Dir1%\c\%_FullDateString%.pdf")Do If %%~zA GTR 9000 (
Echo Printing %%A&Echo=&"%_Exe1%" /t "%_Dir1%\c\%_FullDateString%.pdf")
更新:
现在使用下面的代码有点工作。还有其他方法可以实现吗?
Rem ------------------------------------------------------------------------
Rem 4. Printing files with sizes over 9000 bytes
Set "_Exe1=%ProgramFiles(x86)%\Foxit Software\Foxit Reader\Foxit Reader.exe"
setlocal EnableDelayedExpansion
For %%A In ("%_Dir1%\c\%_FullDateString%.pdf")Do ( set size=%%~zA
if !size! GTR 9000 (
goto PRINT
) else if !size! LSS 9000 (
goto NOPRINT
:NOPRINT
msg * /time:0 /w Printing skipped.. Press "OK" to shutdown the computer"
goto SHUTDOWN
)
)
:PRINT
Echo "Printing %%A&Echo=&"%_Exe1%" /t "%_Dir1%\c\%_FullDateString%.pdf")"
Rem ------------------------------------------------------------------------
Rem 5. Shutting down computer
:SHUTDOWN
echo "%SystemRoot%\System32\shutdown.exe -s -t 60"
PAUSE
我真的认为你不必要地把它复杂化了。您已经在使用 shutdown 命令,它可以向最终用户弹出一个对话框。
Rem ------------------------------------------------------------------------
Rem 4. Printing files with sizes over 9000 bytes
Set "_Exe1=%ProgramFiles(x86)%\Foxit Software\Foxit Reader\Foxit Reader.exe"
Set "_Msg=skipped"
For %%A In ("%_Dir1%\c\%_FullDateString%.pdf")Do If %%~zA GTR 9000 (
Set "_Msg=finished"&Echo Printing %%A&Echo=
"%_Exe1%" /t "%_Dir1%\c\%_FullDateString%.pdf")
Rem ------------------------------------------------------------------------
Rem 5. Shutting down computer
ShutDown /S /T 60 /C "Printing %_Msg%, shutting down your computer." /D P:0:0
注意:这部分是我之前提供的代码的直接替换,它不是基于您在上面发布的任何内容,(问题多多)。
正如我在上一个问题中所建议的,每个线程 1 个问题。所以我在这里提出另一个问题。基本上我想提示用户今天将跳过打印,因为没有要打印的内容,然后用户将按确定,然后代码将继续关闭计算机。我想这样做是为了提醒用户今天的打印工作已经 运行.
所以我尝试了下面的一些代码,它似乎可以工作,但我不知道如何在我的主要代码中实现。
@echo off
Call :Msgbox
if "%errorlevel%"=="1" GOTO SHUTDOWN
exit /b
:Msgbox
echo wscript.quit MsgBox ("Printing skipped.. Press ok to shutdow the computer", 48, "Shutdown Computer") >"%temp%\input.vbs"
wscript //nologo "%temp%\input.vbs"
exit /b
:SHUTDOWN
echo "%SystemRoot%\System32\shutdown.exe -s -t 60"
PAUSE
这是我的主要代码的一部分,我想把代码放在上面。
如果 pdf 文件大小大于 9000 字节 > 今天打印 PDF > 然后转到关机
如果 pdf 文件大小小于 9000 字节 > 使用 msgbox 提示用户 > 用户按确定 > 跳过今天的打印 PDF > 然后转到关机
Rem ------------------------------------------------------------------------
Rem 4. Printing files with sizes over 9000 bytes
Set "_Exe1=%ProgramFiles(x86)%\Foxit Software\Foxit Reader\Foxit Reader.exe"
For %%A In ("%_Dir1%\c\%_FullDateString%.pdf")Do If %%~zA GTR 9000 (
Echo Printing %%A&Echo=&"%_Exe1%" /t "%_Dir1%\c\%_FullDateString%.pdf")
更新: 现在使用下面的代码有点工作。还有其他方法可以实现吗?
Rem ------------------------------------------------------------------------
Rem 4. Printing files with sizes over 9000 bytes
Set "_Exe1=%ProgramFiles(x86)%\Foxit Software\Foxit Reader\Foxit Reader.exe"
setlocal EnableDelayedExpansion
For %%A In ("%_Dir1%\c\%_FullDateString%.pdf")Do ( set size=%%~zA
if !size! GTR 9000 (
goto PRINT
) else if !size! LSS 9000 (
goto NOPRINT
:NOPRINT
msg * /time:0 /w Printing skipped.. Press "OK" to shutdown the computer"
goto SHUTDOWN
)
)
:PRINT
Echo "Printing %%A&Echo=&"%_Exe1%" /t "%_Dir1%\c\%_FullDateString%.pdf")"
Rem ------------------------------------------------------------------------
Rem 5. Shutting down computer
:SHUTDOWN
echo "%SystemRoot%\System32\shutdown.exe -s -t 60"
PAUSE
我真的认为你不必要地把它复杂化了。您已经在使用 shutdown 命令,它可以向最终用户弹出一个对话框。
Rem ------------------------------------------------------------------------
Rem 4. Printing files with sizes over 9000 bytes
Set "_Exe1=%ProgramFiles(x86)%\Foxit Software\Foxit Reader\Foxit Reader.exe"
Set "_Msg=skipped"
For %%A In ("%_Dir1%\c\%_FullDateString%.pdf")Do If %%~zA GTR 9000 (
Set "_Msg=finished"&Echo Printing %%A&Echo=
"%_Exe1%" /t "%_Dir1%\c\%_FullDateString%.pdf")
Rem ------------------------------------------------------------------------
Rem 5. Shutting down computer
ShutDown /S /T 60 /C "Printing %_Msg%, shutting down your computer." /D P:0:0
注意:这部分是我之前提供的代码的直接替换,它不是基于您在上面发布的任何内容,(问题多多)。