我写的批处理文件不会自动关闭或退出

时间:2023-01-17 08:44:29

I made this batch file to close explorer before launching Worms because for some reason my colors get messed up if I don't. The batch file works fine except that it doesn't close when it's finished. What did I do wrong?

我在启动蠕虫之前制作了这个批处理文件以关闭资源管理器,因为出于某种原因,如果我不这样做,我的颜色会搞砸。批处理文件工作正常,但它完成后不会关闭。我做错了什么?

@echo off
echo Closing explorer and launching worms
taskkill /F /IM explorer.exe
"C:\Games\Worms Armageddon - New Edition\wa"
echo Hit any key to resume explorer!
pause
"C:\windows\explorer"
exit

I've tried using start to call the programs and when I use

我尝试使用start来调用程序,当我使用时

start "C:\windows\explorer"

it just opens a new command window and the titlebar says explorer.exe but my taskbar and everything is still gone.

它只是打开一个新的命令窗口,标题栏显示explorer.exe,但我的任务栏,一切都还没有。

1 个解决方案

#1


START is finicky. As per the help:

START非常挑剔。根据帮助:

C:\>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/WAIT] [/B] [command/program]
      [parameters]

    "title"     Title to display in  window title bar.
    ...

As you can see here, the first argument could be a title. It seems that the quotes have a meaning here that could be a title, but not always.

正如你在这里看到的,第一个参数可能是一个标题。似乎引号在这里有一个含义,可能是一个标题,但并非总是如此。

Anyway, instead, try this:

无论如何,相反,试试这个:

start "dummy" "explorer.exe"

Note, you can avoid this by specifying the full path to explorer.exe, like this:

注意,您可以通过指定explorer.exe的完整路径来避免这种情况,如下所示:

start c:\windows\explorer.exe

(note the missing quotes, put the quotes back, and it's a title again).

(注意缺少的引号,将引号放回去,再次是标题)。

As I said, finicky.

正如我所说,挑剔。

#1


START is finicky. As per the help:

START非常挑剔。根据帮助:

C:\>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/WAIT] [/B] [command/program]
      [parameters]

    "title"     Title to display in  window title bar.
    ...

As you can see here, the first argument could be a title. It seems that the quotes have a meaning here that could be a title, but not always.

正如你在这里看到的,第一个参数可能是一个标题。似乎引号在这里有一个含义,可能是一个标题,但并非总是如此。

Anyway, instead, try this:

无论如何,相反,试试这个:

start "dummy" "explorer.exe"

Note, you can avoid this by specifying the full path to explorer.exe, like this:

注意,您可以通过指定explorer.exe的完整路径来避免这种情况,如下所示:

start c:\windows\explorer.exe

(note the missing quotes, put the quotes back, and it's a title again).

(注意缺少的引号,将引号放回去,再次是标题)。

As I said, finicky.

正如我所说,挑剔。