-
December 15th, 2010, 11:32 AM
#1
Problem with Process and file .bat
Hey Guys,
I have an problem with one program that I am developing. My issue is this.
I have one file bat with several commands inside. And this file bat HAVE TO run with Console2(VS2008 Prompt), is not allowed run with cmd.exe.
Then, I want develop an program with C#, that call Console2 and after that call the file bat, to run the file bat inside of the Console2.
My problem is that my program in C# get call the console2, but don´t get call the file bat to run with Console2.
What is happen with my program, anyone can help me.
Following one piece of my code
Process proc = new Process();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.FileName = "C:\\Program Files\\console2\\console.exe";
proc.StartInfo.Arguments = "teste.bat";
proc.Start();
proc.WaitForExit();
Thanks
-
December 15th, 2010, 02:26 PM
#2
Re: Problem with Process and file .bat
The VS command prompt is simply a cmd shell with various environment variables set (this is done with the vcvarsall.bat).
You can replicate the same environment by opening up a cmd.exe process and set the same variables as what is in the vcvarsall.bat file.
-
December 15th, 2010, 03:00 PM
#3
Re: Problem with Process and file .bat
How I do this?
When I use cmd.exe in my program c#, the cmd.exe get call the bat file.
But when I change the "FileName" to Console.exe, my program don´t get call the bat file.
My bat file must run with Console.exe and don´t with cmd.exe.
Just with Console.exe.
-
December 15th, 2010, 05:10 PM
#4
Re: Problem with Process and file .bat
When you say " is not allowed run with cmd.exe.", what do you mean?
If I understand what you are doing, it sounds like you need to setup the environment variables for the console window that you launch.
-
December 15th, 2010, 05:37 PM
#5
Re: Problem with Process and file .bat
The same comment as Arjay already has provided but maybe a little more explicit.
Since cmd.exe starts without any problems there's a good chance that you need some extra parameters when starting console.exe. Check what's done (properties) when you start console.exe from the start menu.
Is it possible to start console.exe (with path) from cmd.exe?
-
December 16th, 2010, 02:57 AM
#6
Re: Problem with Process and file .bat
I guess there is another way to specify the arguments, may be some kind of identifier to specify the filename to be executed by console2.exe
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|