| | |
problem excuting process in different directory
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2009
Posts: 11
Reputation:
Solved Threads: 0
Hi all
I'm literally begging for help here. I have a program that as part of other things, executes a batch file. In visual studio 2008,it works fine either either as debug or release. If I execute it fro the debug/release directories it works fine. if I copy the debug/release directory somewhere else, sdProc.Start() will not execute.
I'm copying it on the same drive. If I move the whole VS project directory it works. I just cant move the debug dir on it's own.
Any help appreciated. I'm just not able to debug the problem.
I'm literally begging for help here. I have a program that as part of other things, executes a batch file. In visual studio 2008,it works fine either either as debug or release. If I execute it fro the debug/release directories it works fine. if I copy the debug/release directory somewhere else, sdProc.Start() will not execute.
I'm copying it on the same drive. If I move the whole VS project directory it works. I just cant move the debug dir on it's own.
Any help appreciated. I'm just not able to debug the problem.
C# Syntax (Toggle Plain Text)
private void RunMacro(string MacroName) { //System.Diagnostics.Debugger.Break(); Process sdProc = new Process(); string strCmdLine = @"D:\" + MacroName + ".bat"; sdProc.StartInfo = new ProcessStartInfo("CMD.exe"); sdProc.StartInfo.Arguments = strCmdLine; sdProc.Start(); sdProc.WaitForExit(132000); sdProc.Close(); }
What exception it is throwing?
How do you know its not working?
How do you know its not working?
Freedom in the Mind, Faith in the words.. Pride in our Souls...
Indian Developer
http://falaque.wordpress.com/
Indian Developer
http://falaque.wordpress.com/
•
•
Join Date: Jul 2009
Posts: 11
Reputation:
Solved Threads: 0
The bat file is never executed as the program in the .bat file would write to a log and show up on screen. everything else is fine. I cant catch any errors, even the lowest 'Exception' but I think there might be an 'InvalidOperationException', even though I cant catch it. I see this when I hover over the proc object while debugging.
To catch very low level exceptions you need to capture stdout and stderr:
Review debug.txt after the execution fails
dos Syntax (Toggle Plain Text)
AppName.exe > debug.txt 2>&1
Review debug.txt after the execution fails
•
•
Join Date: Jul 2009
Posts: 11
Reputation:
Solved Threads: 0
I am so mad at myself for not thinking of that!! The batch file was calling my .net exe which wrote new batch files. I added stderr to that and found the error straight away!
I added a streamwriter line to add
"cd\\"
to the beginning of the batch file and now it works!
(I know you are all wondering why the cmd.exe and batch files... the exe is also calling an old cobol app and it just wont execute properly any other way. it flatly dies if executed from powershell)
Sknake - you are the master! Thanks very much!
I added a streamwriter line to add
"cd\\"
to the beginning of the batch file and now it works!
(I know you are all wondering why the cmd.exe and batch files... the exe is also calling an old cobol app and it just wont execute properly any other way. it flatly dies if executed from powershell)
Sknake - you are the master! Thanks very much!
![]() |
Similar Threads
- Problem reading process output (C#)
- Checking for going up a Directory (PHP)
- given path's format is not supported -virtual directory problem- (C#)
- given path's format is not supported -virtual directory problem- (ASP.NET)
- Can a power problem affect my hard drive? (Cases, Fans and Power Supplies)
- InetCtls.Inet control problem (ASP)
- problem after migration (MySQL)
- problem with icon (Windows NT / 2000 / XP)
- problem with svchost.exe (Windows NT / 2000 / XP)
- C++ Relcat/Attrcat catalog help (C++)
Other Threads in the C# Forum
- Previous Thread: assigning null values
- Next Thread: recommend good online courses for SQL, data controls?
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# cast check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mailmerge mandelbrot math mouseclick mysql operator path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox robot save saving serialization server sleep socket sockets sql sql-server statistics stream string stringformatting sun table tcp text textbox thread time timer update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






