重新启动浏览器。exe只打开一个资源管理器窗口。

时间:2023-01-17 08:49:26

The Problem

这个问题

In one part of a batch file (kind of, see Extra Information) I need to restart Explorer, so I use the, tried-and-tested method of

在批处理文件的一部分(请参阅额外信息)中,我需要重新启动Explorer,因此我使用了试用和测试的方法

taskkill /f /im explorer.exe >nul
explorer.exe

Then this happens

那么这种情况发生

  1. explorer.exe is successfully terminated
  2. 探险家。exe成功终止
  3. explorer.exe is started (see Image 2), but only an Explorer window opens, which I am left with indefinitely (see Image 1)
  4. 探险家。exe启动(参见图2),但只打开一个Explorer窗口,我将无限期地打开该窗口(参见图1)

I can then only properly restart Explorer by starting a new task from Task Manager, as, I'm assuming, Win + R is part of Explorer.

我只能通过从任务管理器启动一个新任务来正确地重新启动资源管理器,我假设,Win + R是资源管理器的一部分。

Extra Information

额外的信息

Now, I say "kind of" as I'm running the batch file from a self-executing SFX archive, created with WinRAR. So, when executed, the contents of the archive are extracted to %temp% and a user-defined file (usually a boot-strapper and, in this case, my batch file) is run upon successful extraction.

现在,当我从一个自执行的SFX归档(使用WinRAR创建)运行批处理文件时,我说“差不多”。因此,在执行时,将归档的内容提取为%temp%,并在成功提取后运行用户定义的文件(通常是引导-strapper,在本例中是我的批处理文件)。

So far, I've deduced

到目前为止,我推断

  1. explorer.exe definitely is being fully killed.
  2. 探险家。exe肯定是被完全杀了。
  3. The batch file definitely is called and executed correctly, as it runs and everything else in the script works as designed, except for the line that starts explorer.exe
  4. 批处理文件肯定会被正确地调用和执行,因为它正在运行,脚本中的所有内容都按照设计工作,除了启动explorer.exe的行
  5. The command to restart Explorer isn't "badly timed", or anything, as I've tried delaying it.
  6. 重新启动资源管理器的命令不是“不合时宜的”,或者别的什么,因为我尝试过延迟它。
  7. The batch file works perfectly when manually extracted from the archive, so it's not a problem with the compression or extraction processes.
  8. 当手工从归档中提取批处理文件时,批处理文件可以很好地工作,所以对压缩或提取过程来说这不是问题。
  9. Even with commands like start explorer.exe | cmd.exe Explorer doesn't restart properly, so it's definitely not a problem with the .bat file.
  10. 即使使用像start explorer这样的命令。exe | cmd。exe资源管理器不能正常重启,所以它绝对不是.bat文件的问题。

I can confirm that it works on Windows XP and Windows 7 x86 but not Windows 7 x64 (which is my system).

我可以确认它适用于Windows XP和Windows 7 x86,但不适用于Windows 7 x64(这是我的系统)。

Status

状态

At the moment, I'm suspicious of WinRAR, as I've proved that the code itself works. So, I'm creating the self-executing SFX with different versions of WinRAR. So far, I've tried versions:

目前,我对WinRAR持怀疑态度,因为我已经证明了代码本身是有效的。因此,我正在创建具有不同版本的WinRAR的自执行SFX。到目前为止,我已经尝试过版本:

  • 4.11 x86
  • 4.11 x86
  • 4.11 x64
  • 4.11 x64
  • 4.20b3 x86
  • 4.20 b3 x86
  • 4.20b3 x64
  • 4.20 b3 x64

and had the same results every time.

每次都有相同的结果。

I submitted a bug report to dev@rarlab.com yesterday and got a reply from Eugene Roshal himself this morning

昨天我向dev@rarlab.com提交了一份bug报告,今天早上我收到了Eugene Roshal的回复。

Hello, SFX module uses ShellExecuteEx to start a setup application. Normally it works well. I do not know why Explorer decides to switch to windowed mode. Now I built a small standalone program

你好,SFX模块使用ShellExecuteEx启动一个安装应用程序。通常它是有效的。我不知道为什么Explorer决定切换到窗口模式。现在我建立了一个小型的独立程序。

#include <windows.h>    
void main()
{
  SHELLEXECUTEINFO si;
  memset(&si,0,sizeof(si));
  si.cbSize=sizeof(si);
  si.lpFile="test.bat";
  si.nShow=SW_SHOWNORMAL;
  ShellExecuteEx(&si);
}

which runs test.bat with contents as in your sample. This program shows exactly the same behavior as WinRAR SFX, so Explorer is started in window.

运行测试。用你的样品里的东西拍。这个程序与WinRAR SFX的行为完全相同,所以Explorer是从窗口开始的。

and a second email this morning

还有今天早上的第二封邮件

Sorry, no advice now. I replaced ShellExecuteEx with CreateProcess

对不起,现在没意见。我用CreateProcess替换了ShellExecuteEx

#include <windows.h>
void main()
{
  STARTUPINFO si;
  PROCESS_INFORMATION pi;
  memset(&si,0,sizeof(si));
  si.cb=sizeof(si);
  CreateProcess(NULL,"test.bat",NULL,NULL,TRUE,0,NULL,NULL,&si,&pi);
}

but result is the same. I tried to use other SW_ flags like SW_SHOWDEFAULT or SW_RESTORE with ShellExecuteEx also as "open" and "explore" lpVerb, but it does not help. For now I do not understand the logic behind this windowed versus desktop mode.

但结果是一样的。我尝试使用其他SW_标志,比如SW_SHOWDEFAULT或SW_RESTORE, ShellExecuteEx也作为“open”和“explore”lpVerb,但没有帮助。现在我还不理解这个窗口和桌面模式背后的逻辑。

I realise the outlook is grim but, I hope that's of help to someone..

我知道前景很黯淡,但我希望这对某人有帮助。

Proof / Evidence

证据证明/

Link to an SFX archive demonstrating this, if anyone wants it: https://dl.dropbox.com/u/27573003/Social%20Distribution/restart-explorer.exe

链接到一个SFX存档,如果有人想要它:https://dl.dropbox.com/u/27573003/Social%20Distribution/restart-explorer.exe。

重新启动浏览器。exe只打开一个资源管理器窗口。

重新启动浏览器。exe只打开一个资源管理器窗口。

You may notice here that I'm running the commands inside a VM (as denoted by VMwareTray.exe) but it is not a VM-caused conflict. I've tested the exact same files on my own host system (which is the same OS) and have had the same results.

您可能注意到,我在VM中运行命令(由VMwareTray.exe表示),但这不是VM引起的冲突。我在我自己的主机系统(相同的操作系统)上测试了完全相同的文件,得到了相同的结果。

Update

更新

I'm experiencing similar "works outside of an SFX archive but not from one" problems when using REG ADD in a completely different project. I just don't think SFX archives play nice with batch files.

我正在经历类似的“在SFX档案之外的工作,但不是从一个”问题,当使用REG添加在一个完全不同的项目。我只是觉得SFX档案不能很好地处理批处理文件。

12 个解决方案

#1


14  

I think user1631170 is on to something, "I wonder if some part of Win-RAR is running in 32-bit mode? Could you even start explorer64 running from a 32-bit process? I am pretty certain that Windows won't do that."

我想user1631170正在做什么,“我想知道Win-RAR的某些部分是否在32位模式下运行?”你能从32位进程开始运行explorer64吗?我很确定Windows不会这么做。

When I start explorer.exe from ProcessHacker (32-bit process manager), I get an explorer window.

当我开始探险家。ProcessHacker(32位进程管理器)中的exe,我获得了一个explorer窗口。

But I can force it to start the 64-bit explorer with this:

但是我可以强制它启动64位浏览器:

%systemroot%\sysnative\cmd.exe /c start /B explorer.exe

sysnative is a keyword that Windows recognizes to bypass the file system redirection for 32-bit/64-bit (http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx Enjoy!

sysnative是一个关键字,Windows识别它可以跳过32位/64位的文件系统重定向(http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85)。

#2


6  

This works in Windows 7:

这适用于Windows 7:

taskkill /f /IM explorer.exe
start explorer.exe
exit

#3


5  

I had this same problem and found that all the solutions here still didn't work from a batch script.

我遇到了同样的问题,发现所有的解决方案仍然没有从批处理脚本中工作。

None of these worked completely:

这些方法都没有完全奏效:

start explorer.exe
start explorer
explorer.exe
explorer

because they all either opened a window (and didn't show the taskbar again), or the batch script then hung thereafter and couldn't execute any more commands

因为它们要么打开了一个窗口(而且没有再次显示任务栏),要么就挂起了批处理脚本,不能执行任何其他命令。

I found that this line in the batch file did work (after killing explorer.exe):

我发现批处理文件中的这一行确实有用(在杀死explorer.exe之后):

start "" "C:\Windows\explorer.exe"

and also allowed other commands to be executed after it in the script

还允许在脚本中执行其他命令。

#4


2  

For restarting explorer.exe, this worked for me.

重新启动浏览器。这对我很有效。

powershell.exe Stop-Process -processname explorer

#5


1  

Try

试一试

%windir%\explorer.exe
start %windir%\explorer.exe
start /d%windir% explorer.exe

#6


0  

I have seen similar problems before doing this in C#. The process had to be invoked by calling explorer shell rather than explorer window, but I haven't had any problems in batch.

我在c#中看到过类似的问题。进程必须通过调用资源管理器shell而不是资源管理器窗口来调用,但是我在批处理中没有遇到任何问题。

Try using this:

试着用这个:

taskkill /im explorer.exe /f
explorer

The difference between the other answers being explorer rather than explorer.exe which has caused problems before for me.

其他答案之间的区别是explorer而不是explorer。这给我带来了问题。

This works on my Win7 x64 PC.

这在我的Win7 x64电脑上工作。

Hope this helps!

希望这可以帮助!

#7


0  

The other day, I was having a look through some of WinRAR's more advanced options and came across this tab:

前几天,我浏览了一下WinRAR的一些更高级的选项,看到了这个选项卡:

重新启动浏览器。exe只打开一个资源管理器窗口。

As soon as I saw that I suspected it to be part of the problem and solution, as this issue only ever occurs on Windows 7 x64.

我一看到这个问题,就怀疑它是问题和解决方案的一部分,因为这个问题只出现在Windows 7 x64上。

As suspected, using the Default64.SFX module instead of the default Default.SFX module entirely fixed the issue. Finally.

如怀疑,使用Default64。SFX模块而不是默认的默认值。SFX模块完全解决了这个问题。最后。

#8


0  

Have same issue with Visual Studio.

Visual Studio也有同样的问题。

What works for me (Win 7 Pro 64bit):

什么对我有效(赢得7pro 64位):

PPM on Project name select "Properties"

项目名称的PPM选择“属性”

Configuration Properties > Build Events > Pre-Build Event

配置属性>构建事件>预构建事件

taskkill /im explorer.exe /f

taskkill / im探险家。exe / f

Configuration Properties > Build Events > Post-Build Event

配置属性>构建事件>后构建事件

start "" "C:\Windows\explorer.exe"

开始”“C:\ Windows \资源管理器”

But this make other problem (the IDE is frozen after the explorer runs) and now I'm only able to restart the IDE to run build command again...

但是,这就产生了其他问题(在explorer运行后,IDE被冻结),现在我只能重新启动IDE来运行构建命令了……

#9


0  

Use this (.bat with administrative privileges) in x64 or x86

使用这个(。具有管理权限的bat)在x64或x86中

tasklist /fi "imagename eq explorer*" | find /i "explorer*"
if not errorlevel 1 (taskkill /f /im "explorer*") else (
start %windir%\explorer.exe

#10


0  

What worked for me in Windows 7 64 bit was "C:\Windows\expstart.exe" or just expstart.exe

在Windows 7 64位中为我工作的是“C:\Windows\expstart”。exe”或只是expstart.exe

#11


0  

Try adding a explorer.exe key to App Paths in the registry.

尝试添加一个探险家。exe键用于注册表中的应用程序路径。

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\explorer.exe

微软HKEY_LOCAL_MACHINE \ SOFTWARE \ \ Windows \ CurrentVersion \ \资源管理器应用程序路径

(Default) C:\Windows\explorer.exe

(默认)C:\Windows\资源管理器

Path C:\Windows

路径C:\Windows

or copy the following to notepad and save it as a .reg file then run it:

或将以下内容复制到记事本,保存为.reg文件,然后运行:


Windows Registry Editor Version 5.00

Windows注册表编辑器版本5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\explorer.exe] @="C:\Windows\explorer.exe" "Path"="C:\Windows"

微软软件\[HKEY_LOCAL_MACHINE \ \ Windows \ CurrentVersion \ \浏览器应用程序路径。exe)@ = " C:\ Windows \探险家。exe”“路径”= " C:\ Windows”

#12


-5  

Easy Context Menu

简单的上下文菜单

Just right-click on the desktop and choose Restart Windows Explorer. Enjoy!

右键单击桌面,选择Restart Windows Explorer。享受吧!

重新启动浏览器。exe只打开一个资源管理器窗口。

#1


14  

I think user1631170 is on to something, "I wonder if some part of Win-RAR is running in 32-bit mode? Could you even start explorer64 running from a 32-bit process? I am pretty certain that Windows won't do that."

我想user1631170正在做什么,“我想知道Win-RAR的某些部分是否在32位模式下运行?”你能从32位进程开始运行explorer64吗?我很确定Windows不会这么做。

When I start explorer.exe from ProcessHacker (32-bit process manager), I get an explorer window.

当我开始探险家。ProcessHacker(32位进程管理器)中的exe,我获得了一个explorer窗口。

But I can force it to start the 64-bit explorer with this:

但是我可以强制它启动64位浏览器:

%systemroot%\sysnative\cmd.exe /c start /B explorer.exe

sysnative is a keyword that Windows recognizes to bypass the file system redirection for 32-bit/64-bit (http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx Enjoy!

sysnative是一个关键字,Windows识别它可以跳过32位/64位的文件系统重定向(http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85)。

#2


6  

This works in Windows 7:

这适用于Windows 7:

taskkill /f /IM explorer.exe
start explorer.exe
exit

#3


5  

I had this same problem and found that all the solutions here still didn't work from a batch script.

我遇到了同样的问题,发现所有的解决方案仍然没有从批处理脚本中工作。

None of these worked completely:

这些方法都没有完全奏效:

start explorer.exe
start explorer
explorer.exe
explorer

because they all either opened a window (and didn't show the taskbar again), or the batch script then hung thereafter and couldn't execute any more commands

因为它们要么打开了一个窗口(而且没有再次显示任务栏),要么就挂起了批处理脚本,不能执行任何其他命令。

I found that this line in the batch file did work (after killing explorer.exe):

我发现批处理文件中的这一行确实有用(在杀死explorer.exe之后):

start "" "C:\Windows\explorer.exe"

and also allowed other commands to be executed after it in the script

还允许在脚本中执行其他命令。

#4


2  

For restarting explorer.exe, this worked for me.

重新启动浏览器。这对我很有效。

powershell.exe Stop-Process -processname explorer

#5


1  

Try

试一试

%windir%\explorer.exe
start %windir%\explorer.exe
start /d%windir% explorer.exe

#6


0  

I have seen similar problems before doing this in C#. The process had to be invoked by calling explorer shell rather than explorer window, but I haven't had any problems in batch.

我在c#中看到过类似的问题。进程必须通过调用资源管理器shell而不是资源管理器窗口来调用,但是我在批处理中没有遇到任何问题。

Try using this:

试着用这个:

taskkill /im explorer.exe /f
explorer

The difference between the other answers being explorer rather than explorer.exe which has caused problems before for me.

其他答案之间的区别是explorer而不是explorer。这给我带来了问题。

This works on my Win7 x64 PC.

这在我的Win7 x64电脑上工作。

Hope this helps!

希望这可以帮助!

#7


0  

The other day, I was having a look through some of WinRAR's more advanced options and came across this tab:

前几天,我浏览了一下WinRAR的一些更高级的选项,看到了这个选项卡:

重新启动浏览器。exe只打开一个资源管理器窗口。

As soon as I saw that I suspected it to be part of the problem and solution, as this issue only ever occurs on Windows 7 x64.

我一看到这个问题,就怀疑它是问题和解决方案的一部分,因为这个问题只出现在Windows 7 x64上。

As suspected, using the Default64.SFX module instead of the default Default.SFX module entirely fixed the issue. Finally.

如怀疑,使用Default64。SFX模块而不是默认的默认值。SFX模块完全解决了这个问题。最后。

#8


0  

Have same issue with Visual Studio.

Visual Studio也有同样的问题。

What works for me (Win 7 Pro 64bit):

什么对我有效(赢得7pro 64位):

PPM on Project name select "Properties"

项目名称的PPM选择“属性”

Configuration Properties > Build Events > Pre-Build Event

配置属性>构建事件>预构建事件

taskkill /im explorer.exe /f

taskkill / im探险家。exe / f

Configuration Properties > Build Events > Post-Build Event

配置属性>构建事件>后构建事件

start "" "C:\Windows\explorer.exe"

开始”“C:\ Windows \资源管理器”

But this make other problem (the IDE is frozen after the explorer runs) and now I'm only able to restart the IDE to run build command again...

但是,这就产生了其他问题(在explorer运行后,IDE被冻结),现在我只能重新启动IDE来运行构建命令了……

#9


0  

Use this (.bat with administrative privileges) in x64 or x86

使用这个(。具有管理权限的bat)在x64或x86中

tasklist /fi "imagename eq explorer*" | find /i "explorer*"
if not errorlevel 1 (taskkill /f /im "explorer*") else (
start %windir%\explorer.exe

#10


0  

What worked for me in Windows 7 64 bit was "C:\Windows\expstart.exe" or just expstart.exe

在Windows 7 64位中为我工作的是“C:\Windows\expstart”。exe”或只是expstart.exe

#11


0  

Try adding a explorer.exe key to App Paths in the registry.

尝试添加一个探险家。exe键用于注册表中的应用程序路径。

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\explorer.exe

微软HKEY_LOCAL_MACHINE \ SOFTWARE \ \ Windows \ CurrentVersion \ \资源管理器应用程序路径

(Default) C:\Windows\explorer.exe

(默认)C:\Windows\资源管理器

Path C:\Windows

路径C:\Windows

or copy the following to notepad and save it as a .reg file then run it:

或将以下内容复制到记事本,保存为.reg文件,然后运行:


Windows Registry Editor Version 5.00

Windows注册表编辑器版本5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\explorer.exe] @="C:\Windows\explorer.exe" "Path"="C:\Windows"

微软软件\[HKEY_LOCAL_MACHINE \ \ Windows \ CurrentVersion \ \浏览器应用程序路径。exe)@ = " C:\ Windows \探险家。exe”“路径”= " C:\ Windows”

#12


-5  

Easy Context Menu

简单的上下文菜单

Just right-click on the desktop and choose Restart Windows Explorer. Enjoy!

右键单击桌面,选择Restart Windows Explorer。享受吧!

重新启动浏览器。exe只打开一个资源管理器窗口。