CMD TaskKill Explorer.exe 减慢打开文件资源管理器的速度

CMD TaskKill Explorer.exe slows down opening File Explorer

我是 运行 Windows 8.1 并且在使用 CMD 重新启动 Explore.exe 时遇到问题。该代码在杀死 explorer.exe 并重新启动它方面起作用,但是一旦这两个代码 运行 我根本无法使用 windows 资源管理器。要解决此问题,我必须通过右键单击并选择重新启动在任务管理器中重新启动 Explorer.exe。我也可以结束进程并转到 'run new task' 并输入 explorer.exe。如果我不这样做,我将无法打开任何文件夹、复制或移动任何文件。我可以修改我的脚本,打开 Firefox,然后打开 chrome。 Excel 运行我的宏速度相同。

为什么 运行 使用这 2 个代码(其中一个)后,文件资源管理器打开和运行速度变慢?


我的代码:

REM ---------------------
REM TaskKill EXPLORER.EXE
REM ---------------------

FOR /F "tokens=1,2" %%A IN (
    'TaskList /FI "IMAGENAME eq EXPLORER.EXE"'
) DO (
    IF /I "%%A" == "EXPLORER.EXE" (
        TaskKill /F /IM %%A >nul
    )
)

REM ------------------
REM START EXPLORER.EXE
REM ------------------

START EXPLORER.EXE >NUL

如果我运行这段代码

也会出现同样的问题
REM ---------------------
REM TaskKill EXPLORER.EXE
REM ---------------------

Taskkill /F /IM EXPLORER.EXE >nul

REM ------------------
REM START EXPLORER.EXE
REM ------------------

START EXPLORER.EXE >NUL

PS 我有注册独立进程 1 来区分 EXPLORER.EXE SHELL 和文件浏览器

SET /A RunningCount=0

rem ----------------------------------------------------------
rem FIGURE OUT HOW MANY WIN EXPLORER.EXE'S THAT ARE RUNNING
rem ----------------------------------------------------------
FOR /F "tokens=1,2,5,6" %%A IN (
    'TASKLIST /FI "IMAGENAME eq EXPLORER.EXE"'
) DO (
    IF /I "%%A" == "EXPLORER.EXE" (
        SET /A RunningCount=!RunningCount!+1
        SET "WinExplorerMemory!RunningCount!=%%C"
        SET "WinExplorerPID!RunningCount!=%%B"
    )
)

rem ----------------------------------------------------------
rem THIS REMOVES THE COMMA'S IN THE STRING
rem ----------------------------------------------------------
IF "%WinExplorerMemory1%" NEQ "" SET WinExplorerMemory1=%WinExplorerMemory1:,=%
IF "%WinExplorerMemory2%" NEQ "" SET WinExplorerMemory2=%WinExplorerMemory2:,=%

rem ----------------------------------------------------------
rem FIGURES OUT WHICH PID IS USING THE MOST MEMORY
rem ----------------------------------------------------------
IF "%RunningCount%" EQU "1" (
    SET WinExplorerShellPID=%WinExplorerPID1%
) ELSE (
    IF [%WinExplorerMemory1%] GTR [%WinExplorerMemory2%] (
        SET WinExplorerShellPID=%WinExplorerPID1%
        TASKKILL /F /PID %WinExplorerPID2% >NUL
    )
    IF [%WinExplorerMemory2%] GTR [%WinExplorerMemory1%] (
        SET WinExplorerShellPID=%WinExplorerPID2%
        TASKKILL /F /PID %WinExplorerPID1% >NUL
    )
)