Aaron
Aaron

Reputation: 4480

Set parameters that can be passed from a batch file to a c# file

I set my variables in a batch file and I want to pass them into a c# file. From what I have found out looking online when passing parameter in a batch file they need to be in form %1 %2 etc. How do I get my variables into %1 %2? Here is my code

@echo off
:: Open Labels

@echo off 

 set name="Aaron "
 ECHO var=%name%
 set company=Company"
 ECHO var=%company%
"C:\Users\akatz\Documents\Visual Studio 2012\Projects\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe %1 %2 

Upvotes: 0

Views: 68

Answers (2)

Hawkmooon
Hawkmooon

Reputation: 508

Change %1 to %name% and %2 to %company%.

Upvotes: 1

Jaguir
Jaguir

Reputation: 3690

%1 and %2 represent what was passed into the batch file. Use your custom variables the same way you do in the echo command:

"C:\...\WindowsFormsApplication1.exe" %name% %company%

For testing, you can prefix the line with an echo to see what it generates without executing.

echo "C:\...\WindowsFormsApplication1.exe" %name% %company%

Upvotes: 1

Related Questions