S
sakulkarni83
Guest
Hi Team,
I am developing Windows Service which will generate csv file through batch file.Later I will read the file.
I am able to generate to the csv file when I execute in Console. The Windows Service generates batch file.
But when I execute it as windows Service Process.WaitForExit does not return.
I individually double click the batch file it executes . Below is the code
Process procstart = new Process();
ProcessStartInfo psi = new ProcessStartInfo
{
CreateNoWindow = true,
UseShellExecute = false,
FileName = "cmd.exe",
Arguments = @"/C "+ BatfileName,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true,
RedirectStandardError = true,
ErrorDialog = false
};
procstart.StartInfo = psi;
procstart.Start();
procstart.WaitForExit();
When I go to location and try to open the file it says FIle is in another process.
When I try to delete the file it says "The action cannot be completed because the file is in open in cmd.exe
Continue reading...
I am developing Windows Service which will generate csv file through batch file.Later I will read the file.
I am able to generate to the csv file when I execute in Console. The Windows Service generates batch file.
But when I execute it as windows Service Process.WaitForExit does not return.
I individually double click the batch file it executes . Below is the code
Process procstart = new Process();
ProcessStartInfo psi = new ProcessStartInfo
{
CreateNoWindow = true,
UseShellExecute = false,
FileName = "cmd.exe",
Arguments = @"/C "+ BatfileName,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true,
RedirectStandardError = true,
ErrorDialog = false
};
procstart.StartInfo = psi;
procstart.Start();
procstart.WaitForExit();
When I go to location and try to open the file it says FIle is in another process.
When I try to delete the file it says "The action cannot be completed because the file is in open in cmd.exe
Continue reading...