Can we execute a batch file (*.bat) using Application Domain?
Thank you in advance.
Can we execute a batch file (*.bat) using Application Domain?
Thank you in advance.
No. AppDomain is a purely CLRs' concept, whereas *.bat files are executed "inside" usual Windows.
If you need to execute a batch file from your C#, use the Process class.
Process myProcess = new Process();
myProcess.StartInfo.FileName = "C:\\HelloWorld.bat";
myProcess.Start();
Batch files are not part of the CLR and therefor cannot be run within an AppDomain.
Application Domains are a purely CLR concept, they have no relevancy to anything that's not a managed library, thus there's no way to run a batch file within an appdomain. The Process object that the batch file runs under will be tied to one specific appdomain, but it will still result in a separate process being instantiated to run your batch file.
There's some fairly good explanatory text under Remarks in the MSDN AppDomain Class documentation that should help you get a handle on what precisely an appdomain is, and what you can and can't do with one.