简体   繁体   中英

C# process.start parameters

We can create a shortcut to an .exe file.

As you know, shortcut files can contain parameters .

I want to build a program that automatically assigns parameters using C # code.

Here is my code:

    private void button4_Click(object sender, EventArgs e)
    {
        HttpWebRequest req =
        WebRequest.Create("http://test.com/contact_ip.txt") as HttpWebRequest;

        HttpWebResponse resp = req.GetResponse() as HttpWebResponse;

        using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
        {
            string ResponseText = sr.ReadToEnd();
            //ResponseText

            System.Diagnostics.Process.Start(".\\folder\\test.exe");
            // e.g.)) test.exe 127.0.0.1(ResponseText) 1234(port)
        }
    }

How do I include the IP address and port at test.exe ?

e.g.)) .\folder\test.exe 127.0.0.1 4455

e.g.2)) Var ResponseText = ip Address

You can try this:

private void button4_Click(object sender, EventArgs e)
{
    HttpWebRequest req =
    WebRequest.Create("http://test.com/contact_ip.txt") as HttpWebRequest;

    HttpWebResponse resp = req.GetResponse() as HttpWebResponse;

    using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
    {
        string ResponseText = sr.ReadToEnd();
        //ResponseText

        System.Diagnostics.Process proc = new System.Diagnostics.Process();
        proc.StartInfo.FileName = @".\\folder\\test.exe";
        proc.StartInfo.Arguments = "127.0.0.1 4455";
        proc.Start();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM