Using this piece of code .exe running in server
string bat =null;
bat = "D:/folder/a.bat";
System.Diagnostics.Process.Start(bat);
Error: Could not find the specified file.
Can anyone help me on this.
Using this piece of code .exe running in server
string bat =null;
bat = "D:/folder/a.bat";
System.Diagnostics.Process.Start(bat);
Error: Could not find the specified file.
Can anyone help me on this.
bat = @"D:\folder\a.bat";
Filepath in Windows doesn't take a forward slash, it's not a URL/URI. Use backslashes.
Anyone of below should work if the program has access to the bat file.
string bat=@"D:\folder\a.bat";
or
string bat="D:\\folder\\a.bat";
Also, checking for the existence of the bat file will be a good practice here:
if(File.Exists(bat))
{
System.Diagnostics.Process.Start(bat);
}
Typically you need to run an executable (like cmd.exe) and then pass it a parameter. cmd.exe specifically has two options /C (carries out the command specified by the string, then terminates) and /K (carries out the command specified by the string but remains open)