minimize a batch file and firefox while running

拟墨画扇 提交于 2019-12-25 04:15:36

问题


Am tryinging to create a batch file that will be scheduled by windows task scheduler .here is my code

start /min test.bat
"C:\Program Files\Mozilla Firefox\firefox.exe"  -tray
TASKKILL /F /IM cmd.exe

however running this in task scheduller causes a bug that runs indefinately which is not desireable.My goal is to run the firefox and the cmd minimized. Using this code with task scheduler works

"C:\Program Files\Mozilla Firefox\firefox.exe"  -tray
 TASKKILL /F /IM cmd.exe

fine however the firefox and cmd are not minimized.What am i doing wrong?is there a tweek arround it?


回答1:


Short version: You can't do that.

Long Version: When someone makes an application, ie. firefox, the entry point of the program is Winmain() which has several parameters given to it by Windows. The fourth parameter is the only one that matters for this. It tells the program how Windows wants it to open. (How you tell Windows to open it) Later in the program, when the window is actually shown with the showWindow() function, the second parameter tells how the programmer wants the window to be displayed. The programmer can then either send it the fourth parameter windows filled for us in the Winmain() function (How you want it displayed), or he can explicitly tell it how he wants it to open (eg. maximized). If the programmer does this, it doesn't matter how you tell the program to open, because it never uses this variable.




回答2:


You can acctually do this by using an external command line tool.Its called nircmd at it works like charm.Here is a how i did it "nircmd.exe" win hide process "firefox.exe" here is a complete doc on its usage nircmd doc



来源:https://stackoverflow.com/questions/15763548/minimize-a-batch-file-and-firefox-while-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!