1

我无法为我的问题找到一个好的答案。也许有人已经有了答案,并且很乐意分享。我正在运行一个批处理文件,并且在某个时间,我想最小化批处理窗口。一些代码稍后,将其最大化或返回到实际大小。

@echo off
mode con cols=100 lines=100
echo My batch is NOT minimized. This message is from a normal window! 
start "window_will_be_minimized" k:\Folder20\MiniMaxi.exe 
start /wait "" cmd /c c:\Folder00\Drawing.exe

Drawing.exe 现在正在运行。

REM --- At this point my batch window is minimized and the MiniMaxi.exe is closed
REM --- until the Drawing.exe is closed.

Drawing.exe 现在已关闭。

REM --- Immediatelly my batch window must return to its previous size.
        Therefore, the MiniMaxi.exe will be launched and then closed

start "window_will_be_MAXImized" k:\Folder20\MiniMaxi.exe
echo Again, this message is from a normal window
pause > nul
exit /b

先感谢您

4

2 回答 2

1

坏消息:批处理文件无法控制自己的窗口是最小还是最大;这必须在调用批处理文件时完成,此时您可以告诉它运行/min、/max 或都不运行/default。新批次将不知道此设置。正如 EitanT 所提到的,它必须由应用程序管理。只有在开始新批次时,您才能控制批次是最小、最大还是正常。

对于时间,您唯一的控制是暂停(就像您在脚本中所做的那样),或者通过执行大约 10 秒的延迟来延迟脚本继续执行的某种方法:

ping -n 10 localhost >nul
于 2012-09-05T04:53:05.590 回答
0

但是,我不能按照您的要求做,如上所述,您可以在最小化最大化默认状态下生成批处​​理文件。以下将创建一个新的批处理,将xmise.bat最小化 并退出。新批次xmise.bat将启动 Drawing.exe,等待,启动原始批次(自定义大小的窗口)并退出。然后原始批次将删除创建的批次xmise.bat

你可以写

一些代码稍后/隐藏的“清理”功能

到 xmise.bat

@echo off
mode con cols=100 lines=100
if "%var%"=="" echo My batch is NOT minimized. This message is from a normal window!
if "%var%"=="created" echo Again, this message is from a normal window
pause>nul 
if "%var%"=="created" del xmise.bat&cls&goto :end
set var=created
echo start /wait "" "Drawing.exe">xmise.bat
echo start "" cmd /c "%~n0.bat">>xmise.bat
echo exit>>xmise.bat
start /min xmise.bat
:end
exit

Drawing.exe 现在正在运行。

REM --- At this point the xmise.bat window is minimized and the original.bat (%~n0.bat) exits
REM --- until the Drawing.exe is closed.

Drawing.exe 现在已关闭。

REM --- Immediatelly my batch window must return to its previous size.
REM --- the original.bat will be relaunched custom size, xmise.bat exits, & then is deleted.
于 2015-08-23T03:34:09.267 回答