0
Answer

Returning value to batch file from c#

vishal verma

vishal verma

10y
513
1
I want to call a c# program from a batch file and then use the output generated from the c# program as  avarable that can be passed on to another c# program from same batch file.
 
dummy c# code-
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:\Users\u316383\Desktop\gre\test.bat");
psi.Arguments = "Evandro 09/08/1977";
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
psi.UseShellExecute = false;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
p.Start();
p.Kill();
System.Console.Read();
}
}
}
 
and my bacth file is :
echo off
echo Name: %1
echo Birth: %2
set v= %1
echo data : v
---
the problem is  though name is dispalyed by taking arguement (%1),but value of v is not getting set as %1.
 
any help will b gratefull.