c# - cmd命令消息不起作用

标签 c# cmd

它只是说“'msg'不被识别为内部或外部程序......” 我已经搜索了很多,但仍然没有找到任何东西。为什么它不认识它?

    private void button1_Click(object sender, EventArgs e)
    {
        string strCmdText;       
        string user = textBox1.Text;
        string host = textBox2.Text;
        string time = textBox3.Text;
        string text = textBox4.Text;

        if (textBox1.Text == "")
        {
            System.Windows.Forms.MessageBox.Show("You haven't specified a user!");
        }
        else if(textBox2.Text == "")
        {
            System.Windows.Forms.MessageBox.Show("You haven't specified the host!");
        }
        else if (textBox3.Text == "")
        {
            System.Windows.Forms.MessageBox.Show("You haven't specified the shutdown timer");
        }
        else
        {
            strCmdText = "/c msg " + user + "/server:" + host + " /time:" + time + " /w " + text;
            System.Diagnostics.Process.Start("CMD.exe", strCmdText);
        }
    }

最佳答案

我猜你有 64 位机器。因此,请尝试指定 msg.exe C:\Windows\Sysnative\msg.exe 的完整路径或添加 C:\Windows\Sysnative 到路径变量。

Source

关于c# - cmd命令消息不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26120533/

相关文章:

c# - ASP.MVC 中包含多个分部 View 的复杂 View

c# - 我可以在 ASP.Net Web API Controller 中使用多个 Get 方法吗

powershell - 批处理以仅从字符串中删除重复的段

java - 如何在java中运行依赖的cmd命令

powershell - 如果不存在,如何将更新的文件复制到新文件夹并创建目录作为源?

c# - 使用无限 while 循环处理客户端/服务器数据的最佳实践

c# - 在 C# 中获取 "append"整数的好方法?

command-line - 命令提示符不会将目录更改到另一个驱动器

windows - 如何在 windows 2012 服务器中终止特定任务

c# - 无法在 Visual Studio 2013 中运行单元测试