473,219 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,219 software developers and data experts.

System.Diagnostics.Process not working !! please help

This is the third newsgroup that I'm posting my problem.
I'm sorry for the multiple posts but the matter becoming urgent.

I hope this is the right place for it...

I have created a very simple batch file (echo hello world) and was trying to
retrieve the standard output but every time I run the code it returns
ExitCode as 1.

The batch file runs just fine from command line.

There is no Win32Exception (no ERROR_FILE_NOT_FOUND and no
ERROR_ACCESS_DENIED)

Also strOutput and strError returns empty.

What ExitCode1 means?

Am I missing on something?

Here is the code:

try
{
System.Diagnostics.Process MFGProc = new System.Diagnostics.Process();
MFGProc.StartInfo.FileName = strMfgWorkDir + strMfgBatFile;
MFGProc.StartInfo.WorkingDirectory = strMfgWorkDir;
MFGProc.StartInfo.UseShellExecute = false;
MFGProc.StartInfo.RedirectStandardError = true;
MFGProc.StartInfo.RedirectStandardOutput = true;
MFGProc.Start();

string strOutput = MFGProc.StandardOutput.ReadToEnd();
string strError = MFGProc.StandardError.ReadToEnd();
MFGProc.WaitForExit();

if (MFGProc.ExitCode == 0)
{
Ok = true;
}
else
{
strErrorMsg = " Running failed. Description: " + strError;
}
}
catch (Win32Exception e)
{
strErrorMsg = "W32 Error:" + e.NativeErrorCode.ToString() + "." +
e.Message ;
}

catch (Exception err)
{
// Process other errors here
strErrorMsg = ("RunMFGCimSession Other error. ErrorMessage: " +
err.Message );
}

Thanks

Nurit


Jan 5 '06 #1
11 3679
Hi,
I just tried your code and it works fine ( with a lil modification) for me,
the strOutput gets the right output. I'm pasting the code here and you check
it works for you or not. Make a new console application and past the code
there:

//--------------<code>
using System;

using System.Diagnostics;
using System.ComponentModel;

namespace ConsoleApplication1
{

class csomething
{
public static void Main()
{
csomething c = new csomething();
c.dosomething();

}
public void dosomething()
{

try
{
System.Diagnostics.Process MFGProc = new System.Diagnostics.Process();
MFGProc.StartInfo.FileName =
AppDomain.CurrentDomain.BaseDirectory+@"bat.bat"; //strMfgWorkDir +
strMfgBatFile;
MFGProc.StartInfo.WorkingDirectory =
AppDomain.CurrentDomain.BaseDirectory;
//@"D:\mycode\ConsoleApplication1\ConsoleApplication 1\bin";
MFGProc.StartInfo.UseShellExecute = false;
MFGProc.StartInfo.RedirectStandardError = true;
MFGProc.StartInfo.RedirectStandardOutput = true;
MFGProc.Start();

string strOutput = MFGProc.StandardOutput.ReadToEnd();
string strError = MFGProc.StandardError.ReadToEnd();
MFGProc.WaitForExit();

if (MFGProc.ExitCode == 0)
{
//Ok = true;
Console.Write("no problem");

}
else
{
//strErrorMsg = " Running failed. Description: " + strError;
Console.Write("some problem");
}
}
catch (Win32Exception e)
{
Console.Write("W32 Error:" + e.NativeErrorCode.ToString() + "." +
e.Message);
}

catch (Exception err)
{
// Process other errors here
Console.Write("RunMFGCimSession Other error. ErrorMessage: " +
err.Message);
}

}

}//class

}

//--------------</code>

make a batch file in your debug bin directory and name it bat.bat and use
notepad to add the "echo hello world" in it.

-Abubakar.

++==
P.S: when pasting your code for others to run, make sure its complete in a
way that anyone can just copy and past it in the editor and it would give
the output that your writing about. Your code had missing variables and
missing using statements. It takes time to change those things and chances
for your getting help reduces. So always submit the complete working code.
Plz read this link http://www.pobox.com/~skeet/csharp/complete.html
-Thanks

"Nurit N" <Nu****@sitqad.co.il> wrote in message
news:eh*************@TK2MSFTNGP12.phx.gbl...
This is the third newsgroup that I'm posting my problem.
I'm sorry for the multiple posts but the matter becoming urgent.

I hope this is the right place for it...

I have created a very simple batch file (echo hello world) and was trying to retrieve the standard output but every time I run the code it returns
ExitCode as 1.

The batch file runs just fine from command line.

There is no Win32Exception (no ERROR_FILE_NOT_FOUND and no
ERROR_ACCESS_DENIED)

Also strOutput and strError returns empty.

What ExitCode1 means?

Am I missing on something?

Here is the code:

try
{
System.Diagnostics.Process MFGProc = new System.Diagnostics.Process();
MFGProc.StartInfo.FileName = strMfgWorkDir + strMfgBatFile;
MFGProc.StartInfo.WorkingDirectory = strMfgWorkDir;
MFGProc.StartInfo.UseShellExecute = false;
MFGProc.StartInfo.RedirectStandardError = true;
MFGProc.StartInfo.RedirectStandardOutput = true;
MFGProc.Start();

string strOutput = MFGProc.StandardOutput.ReadToEnd();
string strError = MFGProc.StandardError.ReadToEnd();
MFGProc.WaitForExit();

if (MFGProc.ExitCode == 0)
{
Ok = true;
}
else
{
strErrorMsg = " Running failed. Description: " + strError;
}
}
catch (Win32Exception e)
{
strErrorMsg = "W32 Error:" + e.NativeErrorCode.ToString() + "." +
e.Message ;
}

catch (Exception err)
{
// Process other errors here
strErrorMsg = ("RunMFGCimSession Other error. ErrorMessage: " +
err.Message );
}

Thanks

Nurit

Jan 5 '06 #2
Thanks for your replay.

I tried the code you sent me and it's working for me as well.

The different (and I'm sorry not to mentioned that before) that I'm running
on a web service application.

My program supposes to start the CMD on the server.

Any Idea?
"Abubakar" <ab*******@gmail.com> wrote in message
news:uE**************@TK2MSFTNGP11.phx.gbl...
Hi,
I just tried your code and it works fine ( with a lil modification) for
me,
the strOutput gets the right output. I'm pasting the code here and you
check
it works for you or not. Make a new console application and past the code
there:

//--------------<code>
using System;

using System.Diagnostics;
using System.ComponentModel;

namespace ConsoleApplication1
{

class csomething
{
public static void Main()
{
csomething c = new csomething();
c.dosomething();

}
public void dosomething()
{

try
{
System.Diagnostics.Process MFGProc = new System.Diagnostics.Process();
MFGProc.StartInfo.FileName =
AppDomain.CurrentDomain.BaseDirectory+@"bat.bat"; //strMfgWorkDir +
strMfgBatFile;
MFGProc.StartInfo.WorkingDirectory =
AppDomain.CurrentDomain.BaseDirectory;
//@"D:\mycode\ConsoleApplication1\ConsoleApplication 1\bin";
MFGProc.StartInfo.UseShellExecute = false;
MFGProc.StartInfo.RedirectStandardError = true;
MFGProc.StartInfo.RedirectStandardOutput = true;
MFGProc.Start();

string strOutput = MFGProc.StandardOutput.ReadToEnd();
string strError = MFGProc.StandardError.ReadToEnd();
MFGProc.WaitForExit();

if (MFGProc.ExitCode == 0)
{
//Ok = true;
Console.Write("no problem");

}
else
{
//strErrorMsg = " Running failed. Description: " + strError;
Console.Write("some problem");
}
}
catch (Win32Exception e)
{
Console.Write("W32 Error:" + e.NativeErrorCode.ToString() + "." +
e.Message);
}

catch (Exception err)
{
// Process other errors here
Console.Write("RunMFGCimSession Other error. ErrorMessage: " +
err.Message);
}

}

}//class

}

//--------------</code>

make a batch file in your debug bin directory and name it bat.bat and use
notepad to add the "echo hello world" in it.

-Abubakar.

++==
P.S: when pasting your code for others to run, make sure its complete in a
way that anyone can just copy and past it in the editor and it would give
the output that your writing about. Your code had missing variables and
missing using statements. It takes time to change those things and chances
for your getting help reduces. So always submit the complete working code.
Plz read this link http://www.pobox.com/~skeet/csharp/complete.html
-Thanks

"Nurit N" <Nu****@sitqad.co.il> wrote in message
news:eh*************@TK2MSFTNGP12.phx.gbl...
This is the third newsgroup that I'm posting my problem.
I'm sorry for the multiple posts but the matter becoming urgent.

I hope this is the right place for it...

I have created a very simple batch file (echo hello world) and was trying

to
retrieve the standard output but every time I run the code it returns
ExitCode as 1.

The batch file runs just fine from command line.

There is no Win32Exception (no ERROR_FILE_NOT_FOUND and no
ERROR_ACCESS_DENIED)

Also strOutput and strError returns empty.

What ExitCode1 means?

Am I missing on something?

Here is the code:

try
{
System.Diagnostics.Process MFGProc = new
System.Diagnostics.Process();
MFGProc.StartInfo.FileName = strMfgWorkDir + strMfgBatFile;
MFGProc.StartInfo.WorkingDirectory = strMfgWorkDir;
MFGProc.StartInfo.UseShellExecute = false;
MFGProc.StartInfo.RedirectStandardError = true;
MFGProc.StartInfo.RedirectStandardOutput = true;
MFGProc.Start();

string strOutput = MFGProc.StandardOutput.ReadToEnd();
string strError = MFGProc.StandardError.ReadToEnd();
MFGProc.WaitForExit();

if (MFGProc.ExitCode == 0)
{
Ok = true;
}
else
{
strErrorMsg = " Running failed. Description: " + strError;
}
}
catch (Win32Exception e)
{
strErrorMsg = "W32 Error:" + e.NativeErrorCode.ToString() + "." +
e.Message ;
}

catch (Exception err)
{
// Process other errors here
strErrorMsg = ("RunMFGCimSession Other error. ErrorMessage: " +
err.Message );
}

Thanks

Nurit


Jan 5 '06 #3

You must be having permissions problem. You need to give approriate
permissions to the directory that you are trying to access on the harddrive
from the virtual directory. You can right click the directory where your
batch file is and goto the "security" tab, add the ASPNET user in it and
give appropriate permissions. Although this would be insecure i beleive but
first try this.

I created a new web appplication to do this in visual studio 2k5, but have
no problems running this code. What exact error do u get when you run this
code?

Ab.

"Nurit N" <Nu****@sitqad.co.il> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
Thanks for your replay.

I tried the code you sent me and it's working for me as well.

The different (and I'm sorry not to mentioned that before) that I'm running on a web service application.

My program supposes to start the CMD on the server.

Any Idea?
"Abubakar" <ab*******@gmail.com> wrote in message
news:uE**************@TK2MSFTNGP11.phx.gbl...
Hi,
I just tried your code and it works fine ( with a lil modification) for
me,
the strOutput gets the right output. I'm pasting the code here and you
check
it works for you or not. Make a new console application and past the code there:

//--------------<code>
using System;

using System.Diagnostics;
using System.ComponentModel;

namespace ConsoleApplication1
{

class csomething
{
public static void Main()
{
csomething c = new csomething();
c.dosomething();

}
public void dosomething()
{

try
{
System.Diagnostics.Process MFGProc = new System.Diagnostics.Process(); MFGProc.StartInfo.FileName =
AppDomain.CurrentDomain.BaseDirectory+@"bat.bat"; //strMfgWorkDir +
strMfgBatFile;
MFGProc.StartInfo.WorkingDirectory =
AppDomain.CurrentDomain.BaseDirectory;
//@"D:\mycode\ConsoleApplication1\ConsoleApplication 1\bin";
MFGProc.StartInfo.UseShellExecute = false;
MFGProc.StartInfo.RedirectStandardError = true;
MFGProc.StartInfo.RedirectStandardOutput = true;
MFGProc.Start();

string strOutput = MFGProc.StandardOutput.ReadToEnd();
string strError = MFGProc.StandardError.ReadToEnd();
MFGProc.WaitForExit();

if (MFGProc.ExitCode == 0)
{
//Ok = true;
Console.Write("no problem");

}
else
{
//strErrorMsg = " Running failed. Description: " + strError;
Console.Write("some problem");
}
}
catch (Win32Exception e)
{
Console.Write("W32 Error:" + e.NativeErrorCode.ToString() + "." +
e.Message);
}

catch (Exception err)
{
// Process other errors here
Console.Write("RunMFGCimSession Other error. ErrorMessage: " +
err.Message);
}

}

}//class

}

//--------------</code>

make a batch file in your debug bin directory and name it bat.bat and use notepad to add the "echo hello world" in it.

-Abubakar.

++==
P.S: when pasting your code for others to run, make sure its complete in a way that anyone can just copy and past it in the editor and it would give the output that your writing about. Your code had missing variables and
missing using statements. It takes time to change those things and chances for your getting help reduces. So always submit the complete working code. Plz read this link http://www.pobox.com/~skeet/csharp/complete.html
-Thanks

"Nurit N" <Nu****@sitqad.co.il> wrote in message
news:eh*************@TK2MSFTNGP12.phx.gbl...
This is the third newsgroup that I'm posting my problem.
I'm sorry for the multiple posts but the matter becoming urgent.

I hope this is the right place for it...

I have created a very simple batch file (echo hello world) and was
trying to
retrieve the standard output but every time I run the code it returns
ExitCode as 1.

The batch file runs just fine from command line.

There is no Win32Exception (no ERROR_FILE_NOT_FOUND and no
ERROR_ACCESS_DENIED)

Also strOutput and strError returns empty.

What ExitCode1 means?

Am I missing on something?

Here is the code:

try
{
System.Diagnostics.Process MFGProc = new
System.Diagnostics.Process();
MFGProc.StartInfo.FileName = strMfgWorkDir + strMfgBatFile;
MFGProc.StartInfo.WorkingDirectory = strMfgWorkDir;
MFGProc.StartInfo.UseShellExecute = false;
MFGProc.StartInfo.RedirectStandardError = true;
MFGProc.StartInfo.RedirectStandardOutput = true;
MFGProc.Start();

string strOutput = MFGProc.StandardOutput.ReadToEnd();
string strError = MFGProc.StandardError.ReadToEnd();
MFGProc.WaitForExit();

if (MFGProc.ExitCode == 0)
{
Ok = true;
}
else
{
strErrorMsg = " Running failed. Description: " + strError;
}
}
catch (Win32Exception e)
{
strErrorMsg = "W32 Error:" + e.NativeErrorCode.ToString() + "." +
e.Message ;
}

catch (Exception err)
{
// Process other errors here
strErrorMsg = ("RunMFGCimSession Other error. ErrorMessage: " +
err.Message );
}

Thanks

Nurit



Jan 5 '06 #4
Thank u again a lot for your replays.

I couldn't add ASPNET user. Gave me: "An object named "ASPNET" cannot be
found."

So I added the EVERYONE user instead for directory and sub-directory and CMD
file it self and gave it full control.

I didnít get any error just ExitCode equals 1.

What does it mean?

In a log file on run time I got:

MFGProc.Start();

MFGProc.HasExited: False
MFGProc.Id: 8096
MFGProc.MachineName: .
MFGProc strOutput:

MFGProc strError:

MFGProc.WaitForExit();
MFGProc.ExitCode: 1

"Abubakar" <ab*******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

You must be having permissions problem. You need to give approriate
permissions to the directory that you are trying to access on the
harddrive
from the virtual directory. You can right click the directory where your
batch file is and goto the "security" tab, add the ASPNET user in it and
give appropriate permissions. Although this would be insecure i beleive
but
first try this.

I created a new web appplication to do this in visual studio 2k5, but
have
no problems running this code. What exact error do u get when you run this
code?

Ab.

"Nurit N" <Nu****@sitqad.co.il> wrote in message
news:uY**************@tk2msftngp13.phx.gbl...
Thanks for your replay.

I tried the code you sent me and it's working for me as well.

The different (and I'm sorry not to mentioned that before) that I'm

running
on a web service application.

My program supposes to start the CMD on the server.

Any Idea?
"Abubakar" <ab*******@gmail.com> wrote in message
news:uE**************@TK2MSFTNGP11.phx.gbl...
> Hi,
> I just tried your code and it works fine ( with a lil modification) for
> me,
> the strOutput gets the right output. I'm pasting the code here and you
> check
> it works for you or not. Make a new console application and past the code > there:
>
> //--------------<code>
> using System;
>
> using System.Diagnostics;
> using System.ComponentModel;
>
> namespace ConsoleApplication1
> {
>
> class csomething
> {
> public static void Main()
> {
> csomething c = new csomething();
> c.dosomething();
>
> }
> public void dosomething()
> {
>
> try
> {
> System.Diagnostics.Process MFGProc = new System.Diagnostics.Process(); > MFGProc.StartInfo.FileName =
> AppDomain.CurrentDomain.BaseDirectory+@"bat.bat"; //strMfgWorkDir +
> strMfgBatFile;
> MFGProc.StartInfo.WorkingDirectory =
> AppDomain.CurrentDomain.BaseDirectory;
> //@"D:\mycode\ConsoleApplication1\ConsoleApplication 1\bin";
> MFGProc.StartInfo.UseShellExecute = false;
> MFGProc.StartInfo.RedirectStandardError = true;
> MFGProc.StartInfo.RedirectStandardOutput = true;
> MFGProc.Start();
>
> string strOutput = MFGProc.StandardOutput.ReadToEnd();
> string strError = MFGProc.StandardError.ReadToEnd();
> MFGProc.WaitForExit();
>
> if (MFGProc.ExitCode == 0)
> {
> //Ok = true;
> Console.Write("no problem");
>
> }
> else
> {
> //strErrorMsg = " Running failed. Description: " + strError;
> Console.Write("some problem");
> }
> }
> catch (Win32Exception e)
> {
> Console.Write("W32 Error:" + e.NativeErrorCode.ToString() + "." +
> e.Message);
> }
>
> catch (Exception err)
> {
> // Process other errors here
> Console.Write("RunMFGCimSession Other error. ErrorMessage: " +
> err.Message);
> }
>
> }
>
> }//class
>
> }
>
> //--------------</code>
>
> make a batch file in your debug bin directory and name it bat.bat and use > notepad to add the "echo hello world" in it.
>
> -Abubakar.
>
> ++==
> P.S: when pasting your code for others to run, make sure its complete
> in a > way that anyone can just copy and past it in the editor and it would give > the output that your writing about. Your code had missing variables and
> missing using statements. It takes time to change those things and chances > for your getting help reduces. So always submit the complete working code. > Plz read this link http://www.pobox.com/~skeet/csharp/complete.html
> -Thanks
>
> "Nurit N" <Nu****@sitqad.co.il> wrote in message
> news:eh*************@TK2MSFTNGP12.phx.gbl...
>> This is the third newsgroup that I'm posting my problem.
>> I'm sorry for the multiple posts but the matter becoming urgent.
>>
>> I hope this is the right place for it...
>>
>>
>>
>> I have created a very simple batch file (echo hello world) and was trying > to
>> retrieve the standard output but every time I run the code it returns
>> ExitCode as 1.
>>
>> The batch file runs just fine from command line.
>>
>> There is no Win32Exception (no ERROR_FILE_NOT_FOUND and no
>> ERROR_ACCESS_DENIED)
>>
>> Also strOutput and strError returns empty.
>>
>> What ExitCode1 means?
>>
>> Am I missing on something?
>>
>> Here is the code:
>>
>> try
>> {
>> System.Diagnostics.Process MFGProc = new
>> System.Diagnostics.Process();
>> MFGProc.StartInfo.FileName = strMfgWorkDir + strMfgBatFile;
>> MFGProc.StartInfo.WorkingDirectory = strMfgWorkDir;
>> MFGProc.StartInfo.UseShellExecute = false;
>> MFGProc.StartInfo.RedirectStandardError = true;
>> MFGProc.StartInfo.RedirectStandardOutput = true;
>> MFGProc.Start();
>>
>> string strOutput = MFGProc.StandardOutput.ReadToEnd();
>> string strError = MFGProc.StandardError.ReadToEnd();
>> MFGProc.WaitForExit();
>>
>> if (MFGProc.ExitCode == 0)
>> {
>> Ok = true;
>> }
>> else
>> {
>> strErrorMsg = " Running failed. Description: " + strError;
>> }
>> }
>> catch (Win32Exception e)
>> {
>> strErrorMsg = "W32 Error:" + e.NativeErrorCode.ToString() + "."
>> +
>> e.Message ;
>> }
>>
>> catch (Exception err)
>> {
>> // Process other errors here
>> strErrorMsg = ("RunMFGCimSession Other error. ErrorMessage: " +
>> err.Message );
>> }
>>
>> Thanks
>>
>> Nurit
>>
>>
>>
>>
>
>



Jan 5 '06 #5
I cant figure out why are you getting that message. My process starts and
exits very fast and my exit code is always 0. What is that log file that you
are viewing, who creats that file?

Ab.

"Nurit N" <Nu****@sitqad.co.il> wrote in message
news:up*************@TK2MSFTNGP15.phx.gbl...
Thank u again a lot for your replays.

I couldn't add ASPNET user. Gave me: "An object named "ASPNET" cannot be
found."

So I added the EVERYONE user instead for directory and sub-directory and CMD file it self and gave it full control.

I didn't get any error just ExitCode equals 1.

What does it mean?

In a log file on run time I got:

MFGProc.Start();

MFGProc.HasExited: False
MFGProc.Id: 8096
MFGProc.MachineName: .
MFGProc strOutput:

MFGProc strError:

MFGProc.WaitForExit();
MFGProc.ExitCode: 1

"Abubakar" <ab*******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

Jan 5 '06 #6
Because I'm running a web service I'm writing on run time to txt file to
debug the program.

Do u have any idea why i don't have ASPNET user on my server?

This is the full function that starts the process:

private bool RunMFGCimSession (string strFileName)

{

bool Ok = false;

try

{

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" In RunMFGCimSession.");

dbg.Close();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc 2: " + strMfgWorkDir +
strMfgBatFile);

dbg.Close();

System.Diagnostics.Process MFGProc = new
System.Diagnostics.Process();

MFGProc.StartInfo.FileName = strMfgWorkDir +
strMfgBatFile;

MFGProc.StartInfo.WorkingDirectory = strMfgWorkDir;

MFGProc.StartInfo.UseShellExecute = false;

MFGProc.EnableRaisingEvents = false;

MFGProc.StartInfo.RedirectStandardError = true;

MFGProc.StartInfo.RedirectStandardOutput = true;

MFGProc.Start();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc.HasExited: " +
MFGProc.HasExited);

dbg.WriteLine(" MFGProc.Id: " + MFGProc.Id);

dbg.WriteLine(" MFGProc.MachineName: " +
MFGProc.MachineName);

dbg.Close();

string strOutput =
MFGProc.StandardOutput.ReadToEnd();

string strError = MFGProc.StandardError.ReadToEnd();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc strOutput: " + strOutput + "
MFGProc strError: " + strError);

dbg.Close();

MFGProc.WaitForExit();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc.ExitCode: " +
MFGProc.ExitCode);

dbg.Close();

if (MFGProc.ExitCode == 0)

{

Ok = true;

}

else

{

strErrorMsg = "RunMFGCimSession error: Running
MFG failed. Description: " + strError;

}

}

catch (Win32Exception e)

{

strErrorMsg = "W32 Error:" +
e.NativeErrorCode.ToString() + "." + e.Message ;

}

catch (Exception err)

{

// Process other errors here

strErrorMsg = ("RunMFGCimSession Other error.
ErrorMessage: " + err.Message );

}

return Ok;

}

"Abubakar" <ab*******@gmail.com> wrote in message
news:uh**************@TK2MSFTNGP14.phx.gbl...
I cant figure out why are you getting that message. My process starts and
exits very fast and my exit code is always 0. What is that log file that
you
are viewing, who creats that file?

Ab.

"Nurit N" <Nu****@sitqad.co.il> wrote in message
news:up*************@TK2MSFTNGP15.phx.gbl...
Thank u again a lot for your replays.

I couldn't add ASPNET user. Gave me: "An object named "ASPNET" cannot be
found."

So I added the EVERYONE user instead for directory and sub-directory and

CMD
file it self and gave it full control.

I didn't get any error just ExitCode equals 1.

What does it mean?

In a log file on run time I got:

MFGProc.Start();

MFGProc.HasExited: False
MFGProc.Id: 8096
MFGProc.MachineName: .
MFGProc strOutput:

MFGProc strError:

MFGProc.WaitForExit();
MFGProc.ExitCode: 1

"Abubakar" <ab*******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...


Jan 5 '06 #7
Why do you want to write all this to the txt file when you can easily step
in the source at the debugger?

ASPNET should be created when the asp.net installs. Its local machine
account, you can try, yourmachinename\ASPNET. I dont know why its not there
in your system.

Since you are already writing to the txt file you already have the rights to
write on the harddrive directly so the permissions thing I wrote about is
not applicable here.

I have tried the source on web application, web service, console, and all
work fine. If you can try to run the same thing on some other machine that
may give you some idea of what the problem is.

Ab.

"Nurit N" <Nu****@sitqad.co.il> wrote in message
news:eR**************@TK2MSFTNGP11.phx.gbl...
Because I'm running a web service I'm writing on run time to txt file to
debug the program.

Do u have any idea why i don't have ASPNET user on my server?

This is the full function that starts the process:

private bool RunMFGCimSession (string strFileName)

{

bool Ok = false;

try

{

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" In RunMFGCimSession.");

dbg.Close();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc 2: " + strMfgWorkDir +
strMfgBatFile);

dbg.Close();

System.Diagnostics.Process MFGProc = new
System.Diagnostics.Process();

MFGProc.StartInfo.FileName = strMfgWorkDir +
strMfgBatFile;

MFGProc.StartInfo.WorkingDirectory = strMfgWorkDir;
MFGProc.StartInfo.UseShellExecute = false;

MFGProc.EnableRaisingEvents = false;

MFGProc.StartInfo.RedirectStandardError = true;

MFGProc.StartInfo.RedirectStandardOutput = true;

MFGProc.Start();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc.HasExited: " +
MFGProc.HasExited);

dbg.WriteLine(" MFGProc.Id: " + MFGProc.Id);

dbg.WriteLine(" MFGProc.MachineName: " +
MFGProc.MachineName);

dbg.Close();

string strOutput =
MFGProc.StandardOutput.ReadToEnd();

string strError = MFGProc.StandardError.ReadToEnd();
dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc strOutput: " + strOutput + " MFGProc strError: " + strError);

dbg.Close();

MFGProc.WaitForExit();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc.ExitCode: " +
MFGProc.ExitCode);

dbg.Close();

if (MFGProc.ExitCode == 0)

{

Ok = true;

}

else

{

strErrorMsg = "RunMFGCimSession error: Running MFG failed. Description: " + strError;

}

}

catch (Win32Exception e)

{

strErrorMsg = "W32 Error:" +
e.NativeErrorCode.ToString() + "." + e.Message ;

}

catch (Exception err)

{

// Process other errors here

strErrorMsg = ("RunMFGCimSession Other error.
ErrorMessage: " + err.Message );

}

return Ok;

}

"Abubakar" <ab*******@gmail.com> wrote in message
news:uh**************@TK2MSFTNGP14.phx.gbl...
I cant figure out why are you getting that message. My process starts and
exits very fast and my exit code is always 0. What is that log file that
you
are viewing, who creats that file?

Ab.

"Nurit N" <Nu****@sitqad.co.il> wrote in message
news:up*************@TK2MSFTNGP15.phx.gbl...
Thank u again a lot for your replays.

I couldn't add ASPNET user. Gave me: "An object named "ASPNET" cannot be found."

So I added the EVERYONE user instead for directory and sub-directory
and CMD
file it self and gave it full control.

I didn't get any error just ExitCode equals 1.

What does it mean?

In a log file on run time I got:

MFGProc.Start();

MFGProc.HasExited: False
MFGProc.Id: 8096
MFGProc.MachineName: .
MFGProc strOutput:

MFGProc strError:

MFGProc.WaitForExit();
MFGProc.ExitCode: 1

"Abubakar" <ab*******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...



Jan 5 '06 #8
"Nurit N" wrote:
Do u have any idea why i don't have ASPNET user on my server?


If you're running on Windows Server 2003, ASP.NET runs under the "Network
Service" account. Is that the case?
Jan 5 '06 #9
Thanks, that's correct :-)
Any way I'm trying to run under other server now (Windows Server 2003)....

"Jeremy Davis" <Je*********@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
"Nurit N" wrote:
Do u have any idea why i don't have ASPNET user on my server?


If you're running on Windows Server 2003, ASP.NET runs under the "Network
Service" account. Is that the case?


Jan 8 '06 #10
I'm trying that and I'll get back to u

Thanks for everything :-)
"Abubakar" <ab*******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Why do you want to write all this to the txt file when you can easily step
in the source at the debugger?

ASPNET should be created when the asp.net installs. Its local machine
account, you can try, yourmachinename\ASPNET. I dont know why its not
there
in your system.

Since you are already writing to the txt file you already have the rights
to
write on the harddrive directly so the permissions thing I wrote about is
not applicable here.

I have tried the source on web application, web service, console, and all
work fine. If you can try to run the same thing on some other machine that
may give you some idea of what the problem is.

Ab.

"Nurit N" <Nu****@sitqad.co.il> wrote in message
news:eR**************@TK2MSFTNGP11.phx.gbl...
Because I'm running a web service I'm writing on run time to txt file to
debug the program.

Do u have any idea why i don't have ASPNET user on my server?

This is the full function that starts the process:

private bool RunMFGCimSession (string strFileName)

{

bool Ok = false;

try

{

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" In RunMFGCimSession.");

dbg.Close();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc 2: " + strMfgWorkDir +
strMfgBatFile);

dbg.Close();

System.Diagnostics.Process MFGProc = new
System.Diagnostics.Process();

MFGProc.StartInfo.FileName = strMfgWorkDir +
strMfgBatFile;

MFGProc.StartInfo.WorkingDirectory =

strMfgWorkDir;

MFGProc.StartInfo.UseShellExecute = false;

MFGProc.EnableRaisingEvents = false;

MFGProc.StartInfo.RedirectStandardError = true;

MFGProc.StartInfo.RedirectStandardOutput = true;

MFGProc.Start();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc.HasExited: " +
MFGProc.HasExited);

dbg.WriteLine(" MFGProc.Id: " + MFGProc.Id);

dbg.WriteLine(" MFGProc.MachineName: " +
MFGProc.MachineName);

dbg.Close();

string strOutput =
MFGProc.StandardOutput.ReadToEnd();

string strError =

MFGProc.StandardError.ReadToEnd();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc strOutput: " + strOutput
+

"
MFGProc strError: " + strError);

dbg.Close();

MFGProc.WaitForExit();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc.ExitCode: " +
MFGProc.ExitCode);

dbg.Close();

if (MFGProc.ExitCode == 0)

{

Ok = true;

}

else

{

strErrorMsg = "RunMFGCimSession error:

Running
MFG failed. Description: " + strError;

}

}

catch (Win32Exception e)

{

strErrorMsg = "W32 Error:" +
e.NativeErrorCode.ToString() + "." + e.Message ;

}

catch (Exception err)

{

// Process other errors here

strErrorMsg = ("RunMFGCimSession Other error.
ErrorMessage: " + err.Message );

}

return Ok;

}

"Abubakar" <ab*******@gmail.com> wrote in message
news:uh**************@TK2MSFTNGP14.phx.gbl...
>I cant figure out why are you getting that message. My process starts
>and
> exits very fast and my exit code is always 0. What is that log file
> that
> you
> are viewing, who creats that file?
>
> Ab.
>
> "Nurit N" <Nu****@sitqad.co.il> wrote in message
> news:up*************@TK2MSFTNGP15.phx.gbl...
>> Thank u again a lot for your replays.
>>
>> I couldn't add ASPNET user. Gave me: "An object named "ASPNET" cannot be >> found."
>>
>> So I added the EVERYONE user instead for directory and sub-directory and > CMD
>> file it self and gave it full control.
>>
>> I didn't get any error just ExitCode equals 1.
>>
>> What does it mean?
>>
>> In a log file on run time I got:
>>
>>
>>
>> MFGProc.Start();
>>
>> MFGProc.HasExited: False
>> MFGProc.Id: 8096
>> MFGProc.MachineName: .
>> MFGProc strOutput:
>>
>> MFGProc strError:
>>
>> MFGProc.WaitForExit();
>> MFGProc.ExitCode: 1
>>
>>
>>
>>
>>
>> "Abubakar" <ab*******@gmail.com> wrote in message
>> news:%2****************@TK2MSFTNGP11.phx.gbl...
>
>




Jan 8 '06 #11
It's working now on the new server. I don't know what the problem was...

Very strange...

I want to thank you very much for the time and efforts :-)

"Abubakar" <ab*******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Why do you want to write all this to the txt file when you can easily step
in the source at the debugger?

ASPNET should be created when the asp.net installs. Its local machine
account, you can try, yourmachinename\ASPNET. I dont know why its not
there
in your system.

Since you are already writing to the txt file you already have the rights
to
write on the harddrive directly so the permissions thing I wrote about is
not applicable here.

I have tried the source on web application, web service, console, and all
work fine. If you can try to run the same thing on some other machine that
may give you some idea of what the problem is.

Ab.

"Nurit N" <Nu****@sitqad.co.il> wrote in message
news:eR**************@TK2MSFTNGP11.phx.gbl...
Because I'm running a web service I'm writing on run time to txt file to
debug the program.

Do u have any idea why i don't have ASPNET user on my server?

This is the full function that starts the process:

private bool RunMFGCimSession (string strFileName)

{

bool Ok = false;

try

{

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" In RunMFGCimSession.");

dbg.Close();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc 2: " + strMfgWorkDir +
strMfgBatFile);

dbg.Close();

System.Diagnostics.Process MFGProc = new
System.Diagnostics.Process();

MFGProc.StartInfo.FileName = strMfgWorkDir +
strMfgBatFile;

MFGProc.StartInfo.WorkingDirectory =

strMfgWorkDir;

MFGProc.StartInfo.UseShellExecute = false;

MFGProc.EnableRaisingEvents = false;

MFGProc.StartInfo.RedirectStandardError = true;

MFGProc.StartInfo.RedirectStandardOutput = true;

MFGProc.Start();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc.HasExited: " +
MFGProc.HasExited);

dbg.WriteLine(" MFGProc.Id: " + MFGProc.Id);

dbg.WriteLine(" MFGProc.MachineName: " +
MFGProc.MachineName);

dbg.Close();

string strOutput =
MFGProc.StandardOutput.ReadToEnd();

string strError =

MFGProc.StandardError.ReadToEnd();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc strOutput: " + strOutput
+

"
MFGProc strError: " + strError);

dbg.Close();

MFGProc.WaitForExit();

dbg = File.AppendText("c:\\temp\\1web.txt");

dbg.WriteLine(" MFGProc.ExitCode: " +
MFGProc.ExitCode);

dbg.Close();

if (MFGProc.ExitCode == 0)

{

Ok = true;

}

else

{

strErrorMsg = "RunMFGCimSession error:

Running
MFG failed. Description: " + strError;

}

}

catch (Win32Exception e)

{

strErrorMsg = "W32 Error:" +
e.NativeErrorCode.ToString() + "." + e.Message ;

}

catch (Exception err)

{

// Process other errors here

strErrorMsg = ("RunMFGCimSession Other error.
ErrorMessage: " + err.Message );

}

return Ok;

}

"Abubakar" <ab*******@gmail.com> wrote in message
news:uh**************@TK2MSFTNGP14.phx.gbl...
>I cant figure out why are you getting that message. My process starts
>and
> exits very fast and my exit code is always 0. What is that log file
> that
> you
> are viewing, who creats that file?
>
> Ab.
>
> "Nurit N" <Nu****@sitqad.co.il> wrote in message
> news:up*************@TK2MSFTNGP15.phx.gbl...
>> Thank u again a lot for your replays.
>>
>> I couldn't add ASPNET user. Gave me: "An object named "ASPNET" cannot be >> found."
>>
>> So I added the EVERYONE user instead for directory and sub-directory and > CMD
>> file it self and gave it full control.
>>
>> I didn't get any error just ExitCode equals 1.
>>
>> What does it mean?
>>
>> In a log file on run time I got:
>>
>>
>>
>> MFGProc.Start();
>>
>> MFGProc.HasExited: False
>> MFGProc.Id: 8096
>> MFGProc.MachineName: .
>> MFGProc strOutput:
>>
>> MFGProc strError:
>>
>> MFGProc.WaitForExit();
>> MFGProc.ExitCode: 1
>>
>>
>>
>>
>>
>> "Abubakar" <ab*******@gmail.com> wrote in message
>> news:%2****************@TK2MSFTNGP11.phx.gbl...
>
>



Jan 8 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: T | last post by:
How do you catch the "Exited" event when a process is terminated. In the following code sample the "myProcess_Exited" event is never called. Any help would be appreciated. using System; using...
2
by: Eranga | last post by:
I have a windows application in C# which has the following method public void InitiateSession(string server,string userName, string passWd ) { //To start the command...
6
by: danl | last post by:
I need to be able to execute a .bat file from a C# web application I have the following code that compliles and seems to run fine, but the bat file never does it's work...
5
by: Paul Bergson | last post by:
I have been trying to get a process to start up and run with arguments passed to it. I have gotten close (Thanks to help from this board) but I there is a failure while I'm running this because...
2
by: Jm | last post by:
Hi all Im using System.Diagnostics.Process.Start to launch external apps from my app but the working directory seems to point to where my app is located. How can i get around this and basically...
2
by: Rupali | last post by:
Hi all, I am tring to call a .vbs file using System.Diagnostics.Process class with following code. Process objProcess = new Process(); objProcess.StartInfo.FileName = "C:\\testScript.vbs";...
3
by: LoDawg | last post by:
I am using the system.diagnostics.process.start command to launch an excel template. Once open the user has the option to create a new template through a wizard I have created. When the wizard...
5
by: garyusenet | last post by:
I have been trying for some time now to launch Internet Explorer from my code. I have read the MSDN notes on this way of starting processes and used their example but couldn't get it to work. I...
1
by: dwcscreenwriterextremesupreme | last post by:
I am trying to automate a mysqldump backup through C# and for some reason the System.Diagnostics.Process is just not working as expected for me. What I want is for the following code to start a...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.