windows 您所在的位置:网站首页 电脑无法打开cmd怎么解决 windows

windows

2024-04-13 10:37| 来源: 网络整理| 查看: 265

在 cmd 或创建批处理文件时,我无法使用命令 msg。当我尝试使用它时,它返回错误 msg 未被识别为内部或外部命令、可运行程序或批处理文件。”我很确定错误是我缺少 msg.exe 在 system32 中,那么有人可以展示如何获取它吗?我正在运行 Windows 8.1。

最佳答案

msg.exe 并非在所有环境的所有 Windows 平台上都可用。

只有 %SystemRoot%\System32\msg.exe(64 位),但没有 %SystemRoot%\SysWOW64\msg.exe(32 位) 在 Windows 7 x64 Enterprise 上,必须使用 %SystemRoot%\Sysnative\msg.exe 从 32 位命令进程中访问 64 位 msg.exe。

有关 System32、SysWOW64 和 Sysnative 的详细信息,请参阅 Microsoft 文档页面 File System Redirector .

这是什么意思?

在 32 位 Windows 上执行的批处理文件需要运行 %SystemRoot%\System32\msg.exe。

在 64 位 Windows 上由 64 位 cmd.exe 执行的批处理文件需要运行 %SystemRoot%\System32\msg.exe。

在 64 位 Windows 上由 32 位 cmd.exe 执行的批处理文件需要运行 %SystemRoot%\Sysnative\msg.exe。

这取决于启动 cmd.exe 的父进程的体系结构或隐式导致启动 cmd.exe 以执行批处理文件的批处理文件,如果批处理文件在 64 位 Windows 上的 32 位或 64 位环境中执行。

因此,从 Windows x64 上的 32 位应用程序或批处理文件 %SystemRoot%\Sysnative 中显式使用 %SystemRoot%\Sysnative\cmd.exe 调用批处理文件\msg.exe 在 Windows x64 机器上使用,而在 Windows x86 机器上分别使用 %SystemRoot%\System32\cmd.exe %SystemRoot%\System32\msg.exe 必须使用。

使用 64 位命令行解释器的第一个变体的演示示例:

名为 MsgDemo.bat 的批处理文件:

@echo off %SystemRoot%\System32\msg.exe /? pause

从在 Windows x64 上运行的 32 位进程调用:

%SystemRoot%\Sysnative\cmd.exe /C MsgDemo.bat

第二个变体的演示示例,引用 msg.exe 正确:

@echo off set "AppMsg=%SystemRoot%\System32\msg.exe" if not "%ProgramFiles(x86)%" == "" ( rem Explicitly reference 64-bit version on Windows x64 as there is rem no 32-bit version. But use Sysnative redirector only if the batch rem file was started with 32-bit cmd.exe as otherwise System32 contains rem msg.exe if it is not missing at all like on Windows 7 Home Premium. if exist %SystemRoot%\Sysnative\* set "AppMsg=%SystemRoot%\Sysnative\msg.exe" ) %AppMsg% /? set "AppMsg=" pause

重定向器 %SystemRoot%\Sysnative 不存在于 64 位进程,仅适用于 32 位进程。

%SystemRoot%\Sysnative 不是目录。因此 if exist %SystemRoot%\Sysnative 不起作用,只是 if exist %SystemRoot%\Sysnative\*。

关于windows - 我不能在 cmd(或批处理)中使用 msg 命令。我怎样才能解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30972651/



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有