简体   繁体   中英

batch send arguments to exe file C#

I'm wanting a batch file, send data to an exe file programmed in C#, and this data will be saved in variables in the program, is this possible? if yes how can i do that?

You can pass parameters via the commandline as documented here :

using System;

class TestClass
{
    static void Main(string[] args)
    {
        // Display the number of command line arguments.
        Console.WriteLine(args.Length);
    }
}

An alternative would be to set environment variables and use their values within the program:

public static string? GetEnvironmentVariable (string variable);

Yes. The standard mechanisms are

  1. The command line

  2. Environment Variables

  3. Standard Input

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