casit
asked on
How to execute .bat from C# service?
Hello I have a C# service that I have created. Inside the .exe after doing certain things I need to be able to execute a .bat file.
I don't have to worry about Input, Output or anything.
Currently I'm using the following and its not working.
I don't have to worry about Input, Output or anything.
Currently I'm using the following and its not working.
ASKER
nope didn't work.
Maybe you could duplicate the actions of the .bat with C#
ASKER
no because the .bat executes a literall program.
Can we see your code ur trying to execute the batch file from the service ? Also the error / other details will be good.
Are you running the service with sufficient privileges to run a .bat file insider?
Are you running the service with sufficient privileges to run a .bat file insider?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
proc.StartInfo.FileName = target;
proc.StartInfo.RedirectSta
proc.StartInfo.RedirectSta
proc.StartInfo.UseShellExe
proc.Start();
proc.WaitForExit
(
(timeout <= 0)
? int.MaxValue : timeout * NO_MILLISECONDS_IN_A_SECON
);
errorMessage = proc.StandardError.ReadToE
proc.WaitForExit();
outputMessage = proc.StandardOutput.ReadTo
proc.WaitForExit();