在.bat文件中以start开头打开另一个程序

时间:2022-03-29 20:49:28

I've been wracking my brain trying to get this to work. I need to write a bat file that will open a program, wait 15 seconds, then open another program. Here's the code I've come up with...

我一直在努力让自己的大脑发挥作用。我需要写一个bat文件,它将打开一个程序,等待15秒,然后打开另一个程序。这是我提出的代码......

@echo off
start "program1.exe"
timeout /t 15 >nul /nobreak
start "program2.exe"

The problem is, program1 runs in fullscreen, and needs to start BEFORE program2. When program2 starts, it minimizes program1.

问题是,program1全屏运行,需要在program2之前启动。当program2启动时,它最小化program1。

Also, program 1 needs to run in a specific resolution, because of my shitty integrated graphics card. program1 has a shortcut function that i normally use. its just " -vidmode 1280, 720, 60". this starts it in the specific resolution that i need. unfortunately, adding that to the .bat file in the form of the following, does not work.

此外,由于我的集成显卡,程序1需要以特定的分辨率运行。 program1有一个我通常使用的快捷功能。它只是“-vidmode 1280,720,60”。这是以我需要的特定分辨率开始的。不幸的是,以下面的形式将其添加到.bat文件中不起作用。

start "program1.exe -vidmode 1280, 720, 60

or

start "program1.exe -vidmode 1280, 720, 60"

Now then, the only way I can think to fix this problem is to have it start a shortcut, like so...

现在,我能想到解决这个问题的唯一方法是让它启动一个快捷方式,就像这样......

start "program1 shortcut.lnk"

Unfortunately, that didn't work either.

不幸的是,这也不起作用。

What can be done to fix this?

可以做些什么来解决这个问题?

2 个解决方案

#1


0  

What about:

start /MIN "program2.exe"

to start the second program minimized?

最小化启动第二个程序?

#2


0  

None of your code snippets work because of where you placed your quotes - the arguments are treated as part of the program name.

由于您放置引号的位置,您的所有代码片段都不起作用 - 参数被视为程序名称的一部分。

Your first one has an opening quote, but no closing quote. It still treats everything that follows as the name of the program to execute.

你的第一个有一个开场报价,但没有收盘报价。它仍然将后面的所有内容视为要执行的程序的名称。

The correct syntax is

正确的语法是

start "" "program1.exe" -vidmode 1280, 720, 60

The quotes around the program name are really only needed if any part of the actual file name (possibly with path info) contains spaces or special characters.

如果实际文件名的任何部分(可能带有路径信息)包含空格或特殊字符,则实际上只需要程序名称周围的引号。

#1


0  

What about:

start /MIN "program2.exe"

to start the second program minimized?

最小化启动第二个程序?

#2


0  

None of your code snippets work because of where you placed your quotes - the arguments are treated as part of the program name.

由于您放置引号的位置,您的所有代码片段都不起作用 - 参数被视为程序名称的一部分。

Your first one has an opening quote, but no closing quote. It still treats everything that follows as the name of the program to execute.

你的第一个有一个开场报价,但没有收盘报价。它仍然将后面的所有内容视为要执行的程序的名称。

The correct syntax is

正确的语法是

start "" "program1.exe" -vidmode 1280, 720, 60

The quotes around the program name are really only needed if any part of the actual file name (possibly with path info) contains spaces or special characters.

如果实际文件名的任何部分(可能带有路径信息)包含空格或特殊字符,则实际上只需要程序名称周围的引号。