How do I minimize the command prompt from my bat f

2019-01-13 20:05发布

I have this bat file and I want to minimize the cmd window when I run it:

@echo off
cd /d C:\leads\ssh 
call C:\Ruby192\bin\setrbvars.bat
ruby C:\leads\ssh\put_leads.rb

Basically I want the command window minimized immediately. Any ideas on how to do this?

12条回答
祖国的老花朵
2楼-- · 2019-01-13 20:39

I don't know if there is a way to minimize a window from a command-prompt once open, but the following article suggests spawning your actual process as a child in a new, pre-minimized window.

http://www.pcreview.co.uk/forums/command-prompt-tool-minimize-command-window-after-starts-t2037434.html

查看更多
戒情不戒烟
3楼-- · 2019-01-13 20:39

If you type this text in your bat file.

start blah.exe /min

It will immediately minimize as soon as it opens the program. You will only see a brief flash of it and it will disappear.

查看更多
成全新的幸福
4楼-- · 2019-01-13 20:40

Another option that works fine for me is to use ConEmu, see http://conemu.github.io/en/ConEmuArgs.html

"C:\Program Files\ConEmu\ConEmu64.exe" -min -run myfile.bat
查看更多
何必那么认真
5楼-- · 2019-01-13 20:41

The only way I know is by creating a Windows shortcut to the batch file and then changing its properties to run minimized by default.

查看更多
狗以群分
6楼-- · 2019-01-13 20:42

One way to 'minimise' the cmd window is to reduce the size of the console using something like...

echo DO NOT CLOSE THIS WINDOW
MODE CON COLS=30 LINES=2

You can reduce the COLS to about 18 and the LINES to 1 if you wish. The advantage is that it works under WinPE, 32-bit or 64-bit, and does not require any 3rd party utility.

查看更多
\"骚年 ilove
7楼-- · 2019-01-13 20:45

You can minimize the command prompt on during the run but you'll need two additional scripts: windowMode and getCmdPid.bat:

@echo off

call getCmdPid
call windowMode -pid %errorlevel% -mode minimized

cd /d C:\leads\ssh 
call C:\Ruby192\bin\setrbvars.bat
ruby C:\leads\ssh\put_leads.rb
查看更多
登录 后发表回答