Windows Server 2008 64 位上的 7-Zip 执行权限

发布于 2024-12-19 22:39:08 字数 495 浏览 3 评论 0原文

我创建了一个自解压 7-Zip 文件。其中包含一个 CMD 文件,7-Zip 在提取时运行该文件。该命令读取注册表并执行一些进一步的活动(对于这个特定问题来说并不重要)。

在 Windows Server 2003 32 位中,此行为运行良好。然而,在 Windows Server 2008 机器上进行的测试表明,7-Zip 启动的 cmd 没有读取注册表的权限。更具体地说,它可以读取某些区域(Windows 当前版本),但不能读取其他区域(其他软件密钥)。

如果我自己获取该 cmd 文件并运行它(从 7-Zip 将其解压缩到的临时文件夹运行它),一切都会正常运行。

使用 UAC“以管理员身份运行”会产生同样的问题,并且禁用 UAC 似乎没有帮助。

我不知道配置文件中有任何 7-Zip 选项告诉它升级权限或类似的东西。我在这里缺少什么吗?在 Windows Server 2008 或 64 位版本的操作系统中,注册表访问是否变得更加锁定?如何确保我的 EXE 文件可以将正确的权限传递给它启动的命令?

I've created a self-extracting 7-Zip file. There is one CMD file contained in it which 7-Zip runs on extract. This cmd reads the registry and performs some further activities (unimportant to this specific question).

In Windows Server 2003 32-bit this behavior works just fine. However, testing on a Windows Server 2008 box shows that the cmd kicked off by 7-Zip doesn't have permissions to read the registry. More specifically it can read some areas (Windows current version), but not others (other software keys).

If I take that cmd file and run it myself (running it from the temporary folder that 7-Zip extracts it to) everything runs fine.

Using UAC "Run as Administrator" produces the same issue, and disabling UAC doesn't seem to help.

I'm not aware of any 7-Zip options for the configuration file that tells it to escalate privileges, or anything like that. Is there something I'm missing here? Has registry access gotten more locked down in Windows Server 2008, or on a 64 bit version of the OS? How can I ensure that my EXE file can pass the right permissions to the command it kicks off?

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

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

发布评论

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

评论(1

温柔戏命师 2024-12-26 22:39:08

由于 7-Zip 文件是 32 位可执行文件,因此您的命令脚本在 32 位上下文中运行。后果之一是某些注册表位置被重定向。有关详细信息,请参阅 MSDN

您可以通过查找环境变量 PROCESSOR_ARCHITEW6432 来检测 WOW64 环境,并且可以通过运行 cmd.exe 中找到的副本返回本机 64 位环境。代码>c:\windows\sysnative。

命令文件顶部的这两行应该可以解决问题:

if defined PROCESSOR_ARCHITEW6432 c:\windows\sysnative\cmd.exe /c %~pf0 %*
if defined PROCESSOR_ARCHITEW6432 goto :eof

Because the 7-Zip file is a 32-bit executable, your command script is running in a 32-bit context. One of the consequences is that certain registry locations are redirected. See MSDN for more details.

You can detect a WOW64 environment by looking for an environment variable, PROCESSOR_ARCHITEW6432 and you can return to the native 64-bit environment by running the copy of cmd.exe found in c:\windows\sysnative.

These two lines at the top of your command file should do the trick:

if defined PROCESSOR_ARCHITEW6432 c:\windows\sysnative\cmd.exe /c %~pf0 %*
if defined PROCESSOR_ARCHITEW6432 goto :eof
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文