Santiago
Santiago

Reputation: 1745

How to get command line args of c# console app with WMIC

I have a simple C# console app that receives and argument with an ID for exec other task and wait for it.

I want to know the ID passed to C# console app with WMIC but it's empty.

The WMIC command is:

WMIC path win32_process where "caption='process_name.exe'" get Commandline

The C# console app was executed in CMD with:

process_name.exe 1

I want to capture the 1 or ID

Upvotes: 0

Views: 289

Answers (1)

Santiago
Santiago

Reputation: 1745

Like @willaien says: Catch the args with string[] args = Environment.GetCommandLineArgs(); solved the issue.

Upvotes: 0

Related Questions