I\'ve created a batch file that is being used with a Process. I currently just have the application pointing to a directory on my local machine.
Rather than having
How about this approach:
of course :
you should run it but with command.com
before
System.Diagnostics.Process.Start("cmd", "/c c:\test\batchFile.bat");
As for embedding the batch file - you can embed just about anything if need be... the answer to this is yes :-)
As for how to use the embedded batch file - the easiest option is the read it from the resource (see http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager.aspx and http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getmanifestresourcestream.aspx) and save it as a real file - then use that.
IF you would embed a .NET EXE/DLL you could use that without saving it as a real file... with a batch file I suspect you will need to save it as a real file.
Probably the most bullet-proof way to do this is to write the .bat out to a temporary file, then run that temporary file.
cmd.exe is, in my experience, rather persnickety and can behave different ways in different contexts. If you want it to behave just like a .bat file that you would run from your filesystem, then you should run the .bat file from your filesystem.
You could try (but I would not recommend) piping the commands to an instance of cmd.exe, but as I say, you may get different behavior.