首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我不能在cmd (或batch )中使用msg命令。我该如何解决这个问题呢?

我不能在cmd (或batch )中使用msg命令。我该如何解决这个问题呢?
EN

Stack Overflow用户
提问于 2015-06-22 13:30:39
回答 2查看 24K关注 0票数 7

在cmd中或制作批处理文件时,我不能使用命令msg。当我尝试使用它时,它返回错误msg is not recognized as an internal or external command, operable program or batch file。“我非常确定错误是我在system32中丢失了一个msg.exe,所以有人能告诉我如何获得它吗?我正在运行Windows8.1。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-06-22 18:27:23

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

在Windows7 x64企业版上只有%SystemRoot%\System32\msg.exe (64位),但没有%SystemRoot%\SysWOW64\msg.exe (32位),因此必须使用%SystemRoot%\Sysnative\msg.exe从32位命令进程中访问64位msg.exe

有关System32SysWOW64Sysnative的详细信息,请参阅微软文档页面File System Redirector

这是什么意思?

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

运行%SystemRoot%\System32\msg.exe.需要运行

  1. 64位cmd.exe在64位Window上执行的批处理文件

运行%SystemRoot%\Sysnative\msg.exe.需要运行

  1. 由32位cmd.exe在64位Window上执行的批处理文件

它取决于父进程启动cmd.exe或批处理文件的体系结构,如果批处理文件在64位Windows32位或64位环境中执行,则会隐含地导致启动cmd.exe以执行批处理文件。

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

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

名为MsgDemo.bat的批处理文件

代码语言:javascript
运行
复制
@echo off
%SystemRoot%\System32\msg.exe /?
pause

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

代码语言:javascript
运行
复制
%SystemRoot%\Sysnative\cmd.exe /C MsgDemo.bat

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

代码语言:javascript
运行
复制
@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\*起作用。

票数 4
EN

Stack Overflow用户

发布于 2018-12-01 17:33:54

从system32中的任何windows 7 PC复制msg.exe并越过目标PC system32目录。

对我来说很好

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30972651

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档