静默删除 Dropbox

发布于 2024-10-08 02:41:44 字数 2442 浏览 0 评论 0原文

我在 Npackd 中使用以下脚本来卸载 Dropbox。它可以在 XP 和 Vista 上运行,但在 Windows 7/64 上失败。它不显示任务栏(通常位于屏幕底部的任务栏),而是显示一个包含 C:/ 内容的 Windows 资源管理器窗口。这与 Dropbox 无关,因为删除其他具有基于 DLL 的 shell 扩展的包也会显示相同的效果。

Uninstall.exe /S _?=%CD%
taskkill /f /fi "IMAGENAME eq explorer.exe"
del DropboxExt.13.dll
del DropboxExt64.13.dll
rem start explorer from the root directory so it does not lock this one
start "" /D\ explorer.exe

脚本有什么问题?如何修改它才能在 Windows 7 上正常工作?

谢谢

编辑:我真的厌倦了这个问题。以下批处理文件可以以普通用户或“以管理员身份”启动:

taskkill /f /fi "IMAGENAME eq explorer.exe"
ping -n 5 127.0.0.1
pushd \
rem runas /trustlevel:0x20000 
start "" /D\ explorer.exe
popd

以下是从我的程序启动 .bat 的代码(路径 =“Uninstall.bat”,仅定义了 2 个新环境变量):

QDir d = this->getDirectory();
QProcess p(0);
p.setProcessChannelMode(QProcess::MergedChannels);
QStringList params;
p.setWorkingDirectory(d.absolutePath());
QString exe = d.absolutePath() + "\\" + path;
for (int i = 0; i < env.count(); i += 2) {
    p.processEnvironment().insert(env.at(i), env.at(i + 1));
}
p.start(exe, params);

相应的代码在 Qt/qprocess_win.cpp 中:

DWORD dwCreationFlags = CREATE_NO_WINDOW;
dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT;
STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
                             (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
                             (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
                             0, 0, 0,
                             STARTF_USESTDHANDLES,
                             0, 0, 0,
                             stdinChannel.pipe[0], stdoutChannel.pipe[1], stderrChannel.pipe[1]
};
success = CreateProcess(0, (wchar_t*)args.utf16(),
                        0, 0, TRUE, dwCreationFlags,
                        environment.isEmpty() ? 0 : envlist.data(),
                        workingDirectory.isEmpty() ? 0 : (wchar_t*)QDir::toNativeSeparators(workingDirectory).utf16(),
                        &startupInfo, pid);

为什么资源管理器认为已经有一个任务栏?

EDIT2:我现在知道出了什么问题。终止 Explorer 后,svchost.exe 进程将自动启动一个新的 Explorer,其参数如下:/factory,{682159d9-c321-47ca-b3f1-30e36b2ec8b9}。 GUID 用于 DesktopExplorerFactory。这可能是 COM 服务的崩溃保护。我对 explorer.exe 的调用不会启动新的资源管理器,因为已经有一个。一两分钟后,如果没有打开任何窗口,此进程将自动关闭。所以我认为 Ben Voigt 是对的,“确实没有什么好方法可以在不注销所有用户的情况下完全卸载 shell。”

I use the following script in Npackd to uninstall Dropbox. It works on XP and Vista, but fails on Windows 7/64. Instead of showing the taskbar (the one that is normally at the bottom of the screen) it shows a Windows Explorer window with the content of C:/. This is not Dropbox related as removing other packages with DLL based shell extensions also shows the same effect.

Uninstall.exe /S _?=%CD%
taskkill /f /fi "IMAGENAME eq explorer.exe"
del DropboxExt.13.dll
del DropboxExt64.13.dll
rem start explorer from the root directory so it does not lock this one
start "" /D\ explorer.exe

What is wrong with the script? How can it be modified to work correctly on Windows 7 too?

Thanks

EDIT: I am really tired of this problem. The following batch file works either started as a normal user or "As Administrator":

taskkill /f /fi "IMAGENAME eq explorer.exe"
ping -n 5 127.0.0.1
pushd \
rem runas /trustlevel:0x20000 
start "" /D\ explorer.exe
popd

Here is the code that starts the .bat from my program (path="Uninstall.bat", only 2 new environment variables are defined):

QDir d = this->getDirectory();
QProcess p(0);
p.setProcessChannelMode(QProcess::MergedChannels);
QStringList params;
p.setWorkingDirectory(d.absolutePath());
QString exe = d.absolutePath() + "\\" + path;
for (int i = 0; i < env.count(); i += 2) {
    p.processEnvironment().insert(env.at(i), env.at(i + 1));
}
p.start(exe, params);

The corresponding code in Qt/qprocess_win.cpp:

DWORD dwCreationFlags = CREATE_NO_WINDOW;
dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT;
STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
                             (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
                             (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
                             0, 0, 0,
                             STARTF_USESTDHANDLES,
                             0, 0, 0,
                             stdinChannel.pipe[0], stdoutChannel.pipe[1], stderrChannel.pipe[1]
};
success = CreateProcess(0, (wchar_t*)args.utf16(),
                        0, 0, TRUE, dwCreationFlags,
                        environment.isEmpty() ? 0 : envlist.data(),
                        workingDirectory.isEmpty() ? 0 : (wchar_t*)QDir::toNativeSeparators(workingDirectory).utf16(),
                        &startupInfo, pid);

Why does the Explorer think there is already a taskbar?

EDIT2: I know what is wrong now. After the Explorer is killed a new is automatically started by an svchost.exe process with the following parameters: /factory,{682159d9-c321-47ca-b3f1-30e36b2ec8b9}. The GUID is for DesktopExplorerFactory. This is probably a crash-protection for a COM service. My calls to explorer.exe do not start a new Explorer as there is already one. After a minute or two this process will be automatically closed if no windows are opened. So I think Ben Voigt is right and "There's really no good way to unload the shell completely without logging off all users."

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ぶ宁プ宁ぶ 2024-10-15 02:41:44

该脚本的问题非常简单:除了 Windows 资源管理器之外,shell 还加载到许多许多应用程序中。每个使用通用打开/保存文件对话框的应用程序都托管外壳。

要解决如何在不传递打开窗口的参数的情况下控制 Windows 资源管理器的工作目录的直接问题,只需设置工作目录即可:

pushd C:\
start explorer.exe
popd

但这仍然无法让您可靠地删除扩展。确实没有什么好方法可以在不注销所有用户的情况下完全卸载 shell。

编辑:您的脚本运行的完整性级别是否与您杀死的原始 explorer.exe 相同?海拔高度相同吗? shell 以中等(正常)完整性级别和未提升的令牌运行,您需要匹配这一点。

What is wrong with the script is quite simple: The shell is loaded into many many applications besides just Windows Explorer. Every application that uses the common open/save file dialogs hosts the shell.

To address your immediate question of how to control the working directory of Windows Explorer without passing arguments that open a window, just set the working directory:

pushd C:\
start explorer.exe
popd

But this still will not let you reliably delete the extension. There's really no good way to unload the shell completely without logging off all users.

EDIT: Is your script running at the same integrity level as the original explorer.exe you killed? Same elevation level? The shell runs with medium (normal) integrity level and unelevated token, you need to match this.

九八野马 2024-10-15 02:41:44

就其价值而言,您的命令“start”/d\ explorer.exe”似乎对我来说即使在win7上也能正常工作,它会重新启动任务栏和任务栏。桌面(如果已被杀死)。

但是,您实际上并不需要“开始”。您可以从批处理文件中调用“explorer.exe”,它不会阻塞。不确定这是否有什么不同,但值得一试。

顺便说一句,如果它不起作用......如果您使用 ctrl+shift+esc 调出任务管理器并执行“文件”->“运行”资源管理器”,受影响的计算机上会发生什么?这会启动任务栏还是会再次生成一个资源管理器窗口?如果这产生了预期的结果,则批处理文件或其环境可能有问题。例如不作为当前登录用户运行等。

如果周围没有其自己的进程的其他实例,则资源管理器应启动任务栏。 shell 本身可能会加载到其他进程中这一事实并不重要...您可以终止资源管理器的所有实例,在 Excel 中显示“文件打开”对话框,并且仍然通过从任务中运行 explorer.exe 来重新启动任务栏经理。

For what it's worth, your command "start "" /d\ explorer.exe" seems to work fine for me even on win7, it restarts the taskbar & desktop if it's been killed.

However, you don't really need "start". You can just call "explorer.exe" from a batch file, it won't block. Not sure if this makes a difference but it's worth a try.

By the way, if it doesn't work... what happens on the affected computer if you bring up the task manager with ctrl+shift+esc and do a File->Run "explorer"? Does that start the taskbar or will it, again, produce an explorer window? If this produces the expected results there may be something wrong with the batch file or its environment. Such as not being run as the currently logged on user, etc.

Explorer should start the taskbar if there are no other instances of its own process around. The fact that the shell itself may be loaded into other processes does not matter... you can kill all instances of explorer, have a "file open" dialog up in Excel, and still restart the taskbar by running explorer.exe from the task manager.

红尘作伴 2024-10-15 02:41:44

尝试将以下行替换

start "" /D\ explorer.exe

为这一行

start "" /D\ %SystemRoot%\explorer.exe

这应该运行不带参数的资源管理器。

问题是,在没有完整路径的情况下运行资源管理器会使用您指定的参数运行它:

/factory,{682159d9-c321-47ca-b3f1-30e36b2ec8b9}

但我不知道为什么会发生这种情况。

Try to replace the following line

start "" /D\ explorer.exe

with this one

start "" /D\ %SystemRoot%\explorer.exe

This should run explorer without parameters.

The thing is that running explorer without full path runs it with parameters you specified:

/factory,{682159d9-c321-47ca-b3f1-30e36b2ec8b9}

but I have no clue why this happens.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文