【问题标题】:MSG.EXE not found, but it's there?未找到 MSG.EXE,但它在那里?
【发布时间】:2017-12-26 02:11:20
【问题描述】:

我无法理解为什么我的 C# process.start 不起作用。下面列出了代码,并且我已验证 msg.exe 位于 C:\Windows\System32\ 文件夹中。我可以很好地使用批处理文件中的命令,也可以使用命令行。由于某种原因,我无法让它在我的 C# 代码中工作。我确实添加了“使用 System.Diagnostics”,这是 Windows 10 Pro。错误是“系统找不到指定的文件”。任何帮助都会很棒。谢谢!

private void btnSend_Click(object sender, EventArgs e)
{
    string mypath = @"C:\Windows\System32\";
    Process.Start(@mypath + "msg.exe " + " * /time:20 hello there");
}

我也用过这个,但是也没用:

private void btnSend_Click(object sender, EventArgs e)
{
    Process.Start(@"C:\Windows\System32\msg.exe * /time:20 hello there");
}

【问题讨论】:

  • Process.start with 2 args...second 是命令行参数

标签: c# process.start


【解决方案1】:

问题是您的文件请求被重定向,因为您试图从 32 位应用程序打开 64 位路径。

你要求:

C:\Windows\System32\msg.exe

不过,Windows 实际上正在搜索这个:

C:\Windows\SysWOW64\msg.exe

您需要使用什么来确保在System32 下查找文件,是这样的:

private void btnSend_Click(object sender, EventArgs e)
{
    Process.Start(@"C:\Windows\Sysnative\msg.exe", "* /time:20 hello there");
}

【讨论】:

  • 谢谢。我已经按照您的建议进行了尝试,但我仍然收到同样的错误,系统找不到指定的文件。也许我在某个地方设置错误?我对为什么这不起作用感到完全困惑。谢谢。
  • @SandraTinch 查看我的编辑。我忘了在参数之间加逗号。
  • 谢谢,效果很好。这让我快疯了!再次感谢您。
猜你喜欢
  • 2013-07-29
  • 2021-01-06
  • 2018-05-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多