如何启动最小化的批处理文件



我想知道如何在不创建快捷方式的情况下启动最小化的批处理文件。

我还想要关于如何在不使用VBS 的情况下最小化重新启动批处理文件的代码

因此,如果有人知道如何从第一次启动开始最小化批处理文件,那就太好了。

试试这个和这个:

@echo off
echo self minimizing
call getCmdPid.bat
call windowMode.bat -pid %errorlevel% -mode minimized
echo --other commands--
pause

通过添加一些powershell

@echo off
echo This batch will minimize and return to normal in 5 second intervals.
timeout /t 5 >nul
powershell -window minimized -command ""
timeout /t 5 >nul
powershell -window normal -command ""
echo and We're back..

如果你只想使用批处理,那么错误的方式,因为我们并没有真正使用start批处理文件,应该是:

start "" /min "batchfilename.cmd"

如果你从另一个批处理文件运行这个,除非你退出,否则该批处理文件将保持打开状态。因此,为了在实际的批处理文件中运行它,它将类似于:

echo Hello!
if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~0" %* && exit
timeout /t 10
exit

这里的超时只会让您有一些时间看到窗口运行最小化。

最新更新