windows 如何隐藏cmd shell窗口?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2277588/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:07:43  来源:igfitidea点击:

how to hide cmd shell window?

windowscmd

提问by bkbkbk

on start up i have a bat file run routine things for me

启动时,我有一个 bat 文件为我运行例行程序

however, the black console pops up and stays open until everything is finished....

但是,黑色控制台会弹出并保持打开状态,直到一切完成....

anyway to hide it and run it in background ? so it shouldn't appear minimized or system tray.

无论如何隐藏它并在后台运行它?所以它不应该出现最小化或系统托盘。

回答by Craig

You can use a VBS script to achieve this. Either write all your code as VBS, or call your batch file like this:

您可以使用 VBS 脚本来实现此目的。要么将所有代码编写为 VBS,要么像这样调用批处理文件:

'launch.vbs
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "mybatch.bat", 0
WshShell = Null

回答by insign

This linkshould help you as helped me. I used the second solution that uses a program named quiet.exe

这个链接应该像帮助我一样帮助你。我使用了第二种解决方案,该解决方案使用名为quiet.exe

To use, just call quiet.exe program params_if_has.

要使用,只需调用quiet.exe program params_if_has.

My use example: quiet.exe php script.php

我的使用示例: quiet.exe php script.php

回答by jamieb

Create a shortcut to the file. On the new shortcut: Right click -> Properties. Go to the Shortcut tab, and choose "Run: Minimized." (This is assuming you're on WinXP).

创建文件的快捷方式。在新快捷方式上:右键单击 -> 属性。转到快捷方式选项卡,然后选择“运行:最小化”。(这是假设您使用的是 WinXP)。

回答by Joey

I once had a little program which could hide windows based on their title. So my startup batch first set a unique title with titleand then called the other program to hide the window with said title. Worked fine but involves a little programming.

我曾经有一个可以根据标题隐藏窗口的小程序。所以我的启动批处理首先设置了一个唯一的标题,title然后调用另一个程序来隐藏带有所述标题的窗口。工作正常,但涉及一些编程。

If you don't want to go that way, then you should use the Task Scheduler as tr4656 noted.

如果您不想那样做,那么您应该使用 tr4656 指出的任务计划程序。

回答by tr4656

You can't really do that but if you are using the scheduler to run the batch file you can select "don't interact with desktop" when creating the job.

您无法真正做到这一点,但如果您使用调度程序运行批处理文件,则可以在创建作业时选择“不与桌面交互”。

回答by Vivin Paliath

Try renaming your file to .cmdinstead of .bat.

尝试将您的文件重命名.cmd.bat.

Or, if you're executing a .exetry:

或者,如果您正在执行.exe尝试:

start "" "C:\Program Files\SomeProg\someprog.exe"

Note: When using "start" you have to be at a command prompt.

注意:使用“开始”时,您必须在命令提示符下。