Lev*_*evi 5 windows batch-file
在cmd或制作批处理文件时,我无法使用该命令msg.当我尝试使用它时,它会返回错误msg is not recognized as an internal or external command, operable program or batch file."我很确定错误是我msg.exe在system32中缺少一个,所以有人可以展示如何获取它吗?我正在运行Windows 8.1.
msg.exe并非在所有环境中的所有 Windows 平台上都可用。
Windows 7 x64 Enterprise 上只有%SystemRoot%\\System32\\msg.exe(64 位),但没有%SystemRoot%\\SysWOW64\\msg.exe(32 位),因此msg.exe必须使用%SystemRoot%\\Sysnative\\msg.exe.
有关 的详细信息System32,SysWOW64请Sysnative参阅 Microsoft 文档页面File\xc2\xa0System Redirector。
这是什么意思?
\n在 32 位 Windows 上执行的批处理文件需要运行%SystemRoot%\\System32\\msg.exe.
在 64 位 Windows 上由 64 位执行的批处理文件cmd.exe需要运行%SystemRoot%\\System32\\msg.exe.
32 位在 64 位 Windows 上执行的批处理文件cmd.exe需要运行%SystemRoot%\\Sysnative\\msg.exe.
它取决于父进程启动cmd.exe或批处理文件的体系结构,cmd.exe如果批处理文件在 64 位 Windows 上的 32 位或 64 位环境中执行,则隐式导致批处理文件开始执行。
%SystemRoot%\\Sysnative\\cmd.exe因此,从 Windows x64 上的 32 位应用程序中显式调用批处理文件,或者%SystemRoot%\\Sysnative\\msg.exe在 \xc2\xa0Windows x64 计算机上使用批处理文件,而在 Windows x86 计算机上则必须%SystemRoot%\\System32\\cmd.exe分别%SystemRoot%\\System32\\msg.exe使用该批处理文件。
使用 64 位命令行解释器的第一个变体的演示示例:
\n批处理文件名称为MsgDemo.bat:
@echo off\n%SystemRoot%\\System32\\msg.exe /?\npause\nRun Code Online (Sandbox Code Playgroud)\n从 Windows x64 上运行的 32 位进程调用:
\n%SystemRoot%\\Sysnative\\cmd.exe /C MsgDemo.bat\nRun Code Online (Sandbox Code Playgroud)\n引用msg.exe正确的第二个变体的演示示例:
@echo off\nset "AppMsg=%SystemRoot%\\System32\\msg.exe"\nif not "%ProgramFiles(x86)%" == "" (\n\n rem Explicitly reference 64-bit version on Windows x64 as there is\n rem no 32-bit version. But use Sysnative redirector only if the batch\n rem file was started with 32-bit cmd.exe as otherwise System32 contains\n rem msg.exe if it is not missing at all like on Windows 7 Home Premium.\n\n if exist %SystemRoot%\\Sysnative\\* set "AppMsg=%SystemRoot%\\Sysnative\\msg.exe"\n)\n%AppMsg% /?\nset "AppMsg="\npause\nRun Code Online (Sandbox Code Playgroud)\n%SystemRoot%\\Sysnative64 位进程不存在重定向器,仅适用于 32 位进程。
%SystemRoot%\\Sysnative不是目录。因此if exist %SystemRoot%\\Sysnative不起作用,只是if exist %SystemRoot%\\Sysnative\\*。