windows 运行批处理脚本时如何最小化命令提示符?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2106723/
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:04:36  来源:igfitidea点击:

how to minimize the command prompt when running a batch script?

windowsbatch-file

提问by issac

anybody know how to minimize the command prompt when running a batch script in Windows 3.11?

有人知道在 Windows 3.11 中运行批处理脚本时如何最小化命令提示符吗?

in Windows XP, there have a command

在 Windows XP 中,有一个命令

start /min start.bat 

to minimize the cmd prompt, is it have similiar command in MSDos 6.22?

最小化 cmd 提示,在 MSDos 6.22 中是否有类似的命令?

回答by rbprogrammer

This little batch code should do what you need.

这个小批量代码应该可以满足您的需求。

http://zoombody.com/articles/run-a-batch-script-minimized

http://zoombody.com/articles/run-a-batch-script-minimized

The relevant code then needs to be placed at the top of your script:

然后需要将相关代码放在脚本的顶部:

if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized
rem Anything after here will run in a minimized window

Here is more informationabout "%~dpnx0".

这里有更多关于 的信息"%~dpnx0"

回答by Greg Hewgill

There isn't a command that you can use from a DOS prompt, however you can create a PIF file that points to your batch file, in which you can set the default window position (including minimized).

没有可以在 DOS 提示符下使用的命令,但是您可以创建一个指向批处理文件的 PIF 文件,您可以在其中设置默认窗口位置(包括最小化)。

...I think. It's been a couple of decades.

...我认为。已经有几十年了。

回答by denezt

How to minimize the current command prompt:

如何最小化当前命令提示符:

Purpose:

目的:

  1. Close a command prompt after execution.
  2. Open a new command prompt using the same path.
  1. 执行后关闭命令提示符。
  2. 使用相同的路径打开一个新的命令提示符。

First open command prompt :Hold down the [Windows]+ [R]keys.

首先打开命令提示符:按住[Windows]+ [R]键。

Go to this location:

去这个位置:

C:\>cd Users\Admin\Desktop

Next excute:

下一步执行:

C:\Users\Admin\Desktop>start /min && exit

Results:
  A new minimized command prompt should open with the same path.

结果:
  一个新的最小化命令提示符应该以相同的路径打开。

Alternatively:
Create a script named minimize.bat and type start /min && exitinto the script and place it in your system32 folder. In order to have the ability to access it via the command prompt.

或者:
创建一个名为minimize.batstart /min && exit的脚本并在脚本中键入并将其放置在您的system32 文件夹中。为了能够通过命令提示符访问它。

回答by Runda Scath na

Windows 10 makes it very easy to start minimized. Simply create a shortcut and click properties. On the shortcut tab half way down is the "Run:" option witch lets you select how you want the command line window to start up. Just select minimized and your command window will remain minimized from the onset. Windows10 properties window of a shortcut

Windows 10 使启动变得非常容易最小化。只需创建一个快捷方式并单击属性。在快捷选项卡的一半下方是“运行:”选项,让您可以选择希望命令行窗口如何启动。只需选择最小化,您的命令窗口将从一开始就保持最小化。 快捷方式的Windows10属性窗口

回答by Rob Kennedy

Use WinExecto start your batch file and pass SW_SHOWMINIMIZEDfor the second parameter.

使用WinExec启动您的批处理文件,并通过SW_SHOWMINIMIZED第二个参数。

See also, How do I run a batch file with WinExec?

另请参阅,如何使用WinExec?