如何从资源启动流程?

时间:2016-11-23 15:53:45

标签: c# process resources skype

我想像按下Win + R一样启动Skype,而不是在运行任务“skype.exe”中输入,这应该在我单击Windows窗体上的按钮时发生。

我只想点击按钮启动Skype,但每次都会崩溃。

   private void button5_Click(object sender, EventArgs e)
    {
        Process X = new Process(); 
        X.StartInfo.FileName = "Skype.exe";        
        X.Start();
        //Process.Start(Properties.Resources.lul);  ||lul is a batch file in the resources which should after running start skype but it doesn´t work :/     
    }

2 个答案:

答案 0 :(得分:0)

是的,最后我自己得到它 - .- 我

private void button5_Click(object sender, EventArgs e)
    {
        Process.Start("C:\\Program Files (x86)\\Skype\\Phone\\Skype.exe");
    }

答案 1 :(得分:-1)

FileName不仅仅是exe的名称,也是它的路径。 这是standard microsoft example

public static void Main()
    {
        Process myProcess = new Process();

        try
        {
            myProcess.StartInfo.UseShellExecute = false;
            // You can start any process, HelloWorld is a do-nothing example.
            myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
            myProcess.StartInfo.CreateNoWindow = true;
            myProcess.Start();
            // This code assumes the process you are starting will terminate itself. 
            // Given that is is started without a window so you cannot terminate it 
            // on the desktop, it must terminate itself or you can do it programmatically
            // from this application using the Kill method.
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }