Objectmix
Tags Register Mark Forums Read

System.Diagnostics.Process() hangs : DOTNET

This is a discussion on System.Diagnostics.Process() hangs within the DOTNET forums in Framework and Interface Programming category; Hi Folks, I have now spend app. 3 days to get the below scenario to work, but can not get there! ..Net version = 2.0.50727 Windows version = Microsoft Windows [Version 5.2.3790] = Windows Server 2003 Now I have to develop a webservice which is run on the server. The webservice will need to invoke an exe (which is a server application exe). Now this exe file needs to be exeucuted as an application user, thus I have the need of starting the process as a application user through the webservice. using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; // ...


Object Mix > Framework and Interface Programming > DOTNET > System.Diagnostics.Process() hangs

DOTNET Discussion forums related to Microsoft Dot net technologies, CSharp and other related items

Reply

 

LinkBack Thread Tools
  #1  
Old 11-06-2007, 09:53 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default System.Diagnostics.Process() hangs

Hi Folks,

I have now spend app. 3 days to get the below scenario to work, but
can not get there!

..Net version = 2.0.50727
Windows version = Microsoft Windows [Version 5.2.3790] = Windows
Server 2003

Now I have to develop a webservice which is run on the server. The
webservice will need to invoke an exe (which is a server application
exe). Now this exe file needs to be exeucuted as an application user,
thus I have the need of starting the process as a application user
through the webservice.

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
// Added
using System.Diagnostics;
using System.Security;
using System.IO;
using System.Configuration;

[WebService(Namespace = "http://intranet.webservices.lundbeck.com/")]
public class TSUsers : System.Web.Services.WebService
{
public TSUsers () {
//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string CreateTSUser(String UserName, String UserEmail)
{
Process p = new Process();

p.StartInfo.UserName =
ConfigurationManager.AppSettings["TSMasterName"];
p.StartInfo.Password = GetSecurePass();
p.StartInfo.Domain = "hlucorp";
//p.StartInfo.LoadUserProfile = true;

p.StartInfo.FileName = @"e:\iw-home\bin\iwuseradm.exe";
p.StartInfo.Arguments = "add-user hluw0447d\\tstest1";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;

try {
p.Start();
p.WaitForExit(1000);

StreamReader srOutput = p.StandardOutput;
StreamReader srError = p.StandardError;
String CmdOutput = srOutput.ReadToEnd();
String CmdError = srError.ReadToEnd();
srError.Close();
srOutput.Close();

return CmdError;
}
catch (Exception ex) {
return ex.Message;
}
}

[WebMethod]
private SecureString GetSecurePass() {
// Different user
SecureString securePass = new SecureString();
String UserPass =
ConfigurationManager.AppSettings["TSMasterPassword"];

foreach (char C in UserPass) {
securePass.AppendChar(C);

}
return securePass;
}
}

Now I can see in the taskmanager that iwuseradm.exe has been started
as the application user, but nothing happens. the whole thing just
hangs!

I have seen a lot of postings on this matter, but not one offered a
solution. Different security issues are discussed etc. but no
solution!

Can anyone help ?

Regards
Saya

Reply With Quote
  #2  
Old 11-06-2007, 10:46 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: System.Diagnostics.Process() hangs

Did you try to mannually execute the proces with the given parameters.
It might be that the executing process is waiting for input....

On Tue, 06 Nov 2007 06:53:55 -0800, Saya <vaqas@hotmail.com> wrote:

>Hi Folks,
>
>I have now spend app. 3 days to get the below scenario to work, but
>can not get there!
>
>.Net version = 2.0.50727
>Windows version = Microsoft Windows [Version 5.2.3790] = Windows
>Server 2003
>
>Now I have to develop a webservice which is run on the server. The
>webservice will need to invoke an exe (which is a server application
>exe). Now this exe file needs to be exeucuted as an application user,
>thus I have the need of starting the process as a application user
>through the webservice.
>
>using System;
>using System.Web;
>using System.Web.Services;
>using System.Web.Services.Protocols;
>// Added
>using System.Diagnostics;
>using System.Security;
>using System.IO;
>using System.Configuration;
>
>[WebService(Namespace = "http://intranet.webservices.lundbeck.com/")]
>public class TSUsers : System.Web.Services.WebService
>{
> public TSUsers () {
> //Uncomment the following line if using designed components
> //InitializeComponent();
> }
>
> [WebMethod]
> public string CreateTSUser(String UserName, String UserEmail)
>{
> Process p = new Process();
>
> p.StartInfo.UserName =
>ConfigurationManager.AppSettings["TSMasterName"];
> p.StartInfo.Password = GetSecurePass();
> p.StartInfo.Domain = "hlucorp";
> //p.StartInfo.LoadUserProfile = true;
>
> p.StartInfo.FileName = @"e:\iw-home\bin\iwuseradm.exe";
> p.StartInfo.Arguments = "add-user hluw0447d\\tstest1";
> p.StartInfo.UseShellExecute = false;
> p.StartInfo.CreateNoWindow = true;
> p.StartInfo.RedirectStandardOutput = true;
> p.StartInfo.RedirectStandardError = true;
>
> try {
> p.Start();
> p.WaitForExit(1000);
>
> StreamReader srOutput = p.StandardOutput;
> StreamReader srError = p.StandardError;
> String CmdOutput = srOutput.ReadToEnd();
> String CmdError = srError.ReadToEnd();
> srError.Close();
> srOutput.Close();
>
> return CmdError;
> }
> catch (Exception ex) {
> return ex.Message;
> }
> }
>
> [WebMethod]
> private SecureString GetSecurePass() {
> // Different user
> SecureString securePass = new SecureString();
> String UserPass =
>ConfigurationManager.AppSettings["TSMasterPassword"];
>
> foreach (char C in UserPass) {
> securePass.AppendChar(C);
>
> }
> return securePass;
> }
>}
>
>Now I can see in the taskmanager that iwuseradm.exe has been started
>as the application user, but nothing happens. the whole thing just
>hangs!
>
>I have seen a lot of postings on this matter, but not one offered a
>solution. Different security issues are discussed etc. but no
>solution!
>
>Can anyone help ?
>
>Regards
>Saya

Reply With Quote
  #3  
Old 11-06-2007, 11:21 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default RE: System.Diagnostics.Process() hangs

you coded a deadly embrace.

you redirected output & input, then did a wait for task exit. but it cannot
exit until it writes its output, which you won't read until it exits. thus a
hang.

-- bruce (sqlwork.com)


"Saya" wrote:

> Hi Folks,
>
> I have now spend app. 3 days to get the below scenario to work, but
> can not get there!
>
> ..Net version = 2.0.50727
> Windows version = Microsoft Windows [Version 5.2.3790] = Windows
> Server 2003
>
> Now I have to develop a webservice which is run on the server. The
> webservice will need to invoke an exe (which is a server application
> exe). Now this exe file needs to be exeucuted as an application user,
> thus I have the need of starting the process as a application user
> through the webservice.
>
> using System;
> using System.Web;
> using System.Web.Services;
> using System.Web.Services.Protocols;
> // Added
> using System.Diagnostics;
> using System.Security;
> using System.IO;
> using System.Configuration;
>
> [WebService(Namespace = "http://intranet.webservices.lundbeck.com/")]
> public class TSUsers : System.Web.Services.WebService
> {
> public TSUsers () {
> //Uncomment the following line if using designed components
> //InitializeComponent();
> }
>
> [WebMethod]
> public string CreateTSUser(String UserName, String UserEmail)
> {
> Process p = new Process();
>
> p.StartInfo.UserName =
> ConfigurationManager.AppSettings["TSMasterName"];
> p.StartInfo.Password = GetSecurePass();
> p.StartInfo.Domain = "hlucorp";
> //p.StartInfo.LoadUserProfile = true;
>
> p.StartInfo.FileName = @"e:\iw-home\bin\iwuseradm.exe";
> p.StartInfo.Arguments = "add-user hluw0447d\\tstest1";
> p.StartInfo.UseShellExecute = false;
> p.StartInfo.CreateNoWindow = true;
> p.StartInfo.RedirectStandardOutput = true;
> p.StartInfo.RedirectStandardError = true;
>
> try {
> p.Start();
> p.WaitForExit(1000);
>
> StreamReader srOutput = p.StandardOutput;
> StreamReader srError = p.StandardError;
> String CmdOutput = srOutput.ReadToEnd();
> String CmdError = srError.ReadToEnd();
> srError.Close();
> srOutput.Close();
>
> return CmdError;
> }
> catch (Exception ex) {
> return ex.Message;
> }
> }
>
> [WebMethod]
> private SecureString GetSecurePass() {
> // Different user
> SecureString securePass = new SecureString();
> String UserPass =
> ConfigurationManager.AppSettings["TSMasterPassword"];
>
> foreach (char C in UserPass) {
> securePass.AppendChar(C);
>
> }
> return securePass;
> }
> }
>
> Now I can see in the taskmanager that iwuseradm.exe has been started
> as the application user, but nothing happens. the whole thing just
> hangs!
>
> I have seen a lot of postings on this matter, but not one offered a
> solution. Different security issues are discussed etc. but no
> solution!
>
> Can anyone help ?
>
> Regards
> Saya
>
>

Reply With Quote
  #4  
Old 11-12-2007, 04:38 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: System.Diagnostics.Process() hangs

Hi John,

Yes I have tried the command manually, and it works fine, with the
user that I am impersonating.
The command is such that if the paramters are not supplied it responds
immediately with error.


On 6 Nov., 16:46, John MJ Gorter <john.gor...@gmail.com> wrote:
> Did you try to mannually execute the proces with the given parameters.
> It might be that the executing process is waiting for input....
>
>
>
> On Tue, 06 Nov 2007 06:53:55 -0800,Saya<va...@hotmail.com> wrote:
> >Hi Folks,

>
> >I have now spend app. 3 days to get the below scenario to work, but
> >can not get there!

>
> >.Net version = 2.0.50727
> >Windows version = Microsoft Windows [Version 5.2.3790] = Windows
> >Server 2003

>
> >Now I have to develop a webservice which is run on the server. The
> >webservice will need to invoke an exe (which is a server application
> >exe). Now this exe file needs to be exeucuted as an application user,
> >thus I have the need of starting the process as a application user
> >through the webservice.

>
> >using System;
> >using System.Web;
> >using System.Web.Services;
> >using System.Web.Services.Protocols;
> >// Added
> >using System.Diagnostics;
> >using System.Security;
> >using System.IO;
> >using System.Configuration;

>
> >[WebService(Namespace = "http://intranet.webservices.lundbeck.com/")]
> >public class TSUsers : System.Web.Services.WebService
> >{
> > public TSUsers () {
> > //Uncomment the following line if using designed components
> > //InitializeComponent();
> > }

>
> > [WebMethod]
> > public string CreateTSUser(String UserName, String UserEmail)
> >{
> > Process p = new Process();

>
> > p.StartInfo.UserName =
> >ConfigurationManager.AppSettings["TSMasterName"];
> > p.StartInfo.Password = GetSecurePass();
> > p.StartInfo.Domain = "hlucorp";
> > //p.StartInfo.LoadUserProfile = true;

>
> > p.StartInfo.FileName = @"e:\iw-home\bin\iwuseradm.exe";
> > p.StartInfo.Arguments = "add-user hluw0447d\\tstest1";
> > p.StartInfo.UseShellExecute = false;
> > p.StartInfo.CreateNoWindow = true;
> > p.StartInfo.RedirectStandardOutput = true;
> > p.StartInfo.RedirectStandardError = true;

>
> > try {
> > p.Start();
> > p.WaitForExit(1000);

>
> > StreamReader srOutput = p.StandardOutput;
> > StreamReader srError = p.StandardError;
> > String CmdOutput = srOutput.ReadToEnd();
> > String CmdError = srError.ReadToEnd();
> > srError.Close();
> > srOutput.Close();

>
> > return CmdError;
> > }
> > catch (Exception ex) {
> > return ex.Message;
> > }
> > }

>
> > [WebMethod]
> > private SecureString GetSecurePass() {
> > // Different user
> > SecureString securePass = new SecureString();
> > String UserPass =
> >ConfigurationManager.AppSettings["TSMasterPassword"];

>
> > foreach (char C in UserPass) {
> > securePass.AppendChar(C);

>
> > }
> > return securePass;
> > }
> >}

>
> >Now I can see in the taskmanager that iwuseradm.exe has been started
> >as the application user, but nothing happens. the whole thing just
> >hangs!

>
> >I have seen a lot of postings on this matter, but not one offered a
> >solution. Different security issues are discussed etc. but no
> >solution!

>
> >Can anyone help ?

>
> >Regards
> >Saya- Skjul tekst i anførselstegn -

>
> - Vis tekst i anførselstegn -



Reply With Quote
  #5  
Old 11-12-2007, 08:16 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: System.Diagnostics.Process() hangs

Does it have any dialog boxes like asking yes/no?
If so then you will not see it and can not click button.

George


"Saya" <vaqas@hotmail.com> wrote in message
news:1194860309.319364.61790@k79g2000hse.googlegro ups.com...
Hi John,

Yes I have tried the command manually, and it works fine, with the
user that I am impersonating.
The command is such that if the paramters are not supplied it responds
immediately with error.


On 6 Nov., 16:46, John MJ Gorter <john.gor...@gmail.com> wrote:
> Did you try to mannually execute the proces with the given parameters.
> It might be that the executing process is waiting for input....
>
>
>
> On Tue, 06 Nov 2007 06:53:55 -0800,Saya<va...@hotmail.com> wrote:
> >Hi Folks,

>
> >I have now spend app. 3 days to get the below scenario to work, but
> >can not get there!

>
> >.Net version = 2.0.50727
> >Windows version = Microsoft Windows [Version 5.2.3790] = Windows
> >Server 2003

>
> >Now I have to develop a webservice which is run on the server. The
> >webservice will need to invoke an exe (which is a server application
> >exe). Now this exe file needs to be exeucuted as an application user,
> >thus I have the need of starting the process as a application user
> >through the webservice.

>
> >using System;
> >using System.Web;
> >using System.Web.Services;
> >using System.Web.Services.Protocols;
> >// Added
> >using System.Diagnostics;
> >using System.Security;
> >using System.IO;
> >using System.Configuration;

>
> >[WebService(Namespace = "http://intranet.webservices.lundbeck.com/")]
> >public class TSUsers : System.Web.Services.WebService
> >{
> > public TSUsers () {
> > //Uncomment the following line if using designed components
> > //InitializeComponent();
> > }

>
> > [WebMethod]
> > public string CreateTSUser(String UserName, String UserEmail)
> >{
> > Process p = new Process();

>
> > p.StartInfo.UserName =
> >ConfigurationManager.AppSettings["TSMasterName"];
> > p.StartInfo.Password = GetSecurePass();
> > p.StartInfo.Domain = "hlucorp";
> > //p.StartInfo.LoadUserProfile = true;

>
> > p.StartInfo.FileName = @"e:\iw-home\bin\iwuseradm.exe";
> > p.StartInfo.Arguments = "add-user hluw0447d\\tstest1";
> > p.StartInfo.UseShellExecute = false;
> > p.StartInfo.CreateNoWindow = true;
> > p.StartInfo.RedirectStandardOutput = true;
> > p.StartInfo.RedirectStandardError = true;

>
> > try {
> > p.Start();
> > p.WaitForExit(1000);

>
> > StreamReader srOutput = p.StandardOutput;
> > StreamReader srError = p.StandardError;
> > String CmdOutput = srOutput.ReadToEnd();
> > String CmdError = srError.ReadToEnd();
> > srError.Close();
> > srOutput.Close();

>
> > return CmdError;
> > }
> > catch (Exception ex) {
> > return ex.Message;
> > }
> > }

>
> > [WebMethod]
> > private SecureString GetSecurePass() {
> > // Different user
> > SecureString securePass = new SecureString();
> > String UserPass =
> >ConfigurationManager.AppSettings["TSMasterPassword"];

>
> > foreach (char C in UserPass) {
> > securePass.AppendChar(C);

>
> > }
> > return securePass;
> > }
> >}

>
> >Now I can see in the taskmanager that iwuseradm.exe has been started
> >as the application user, but nothing happens. the whole thing just
> >hangs!

>
> >I have seen a lot of postings on this matter, but not one offered a
> >solution. Different security issues are discussed etc. but no
> >solution!

>
> >Can anyone help ?

>
> >Regards
> >Saya- Skjul tekst i anførselstegn -

>
> - Vis tekst i anførselstegn -




Reply With Quote
  #6  
Old 11-13-2007, 07:20 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: System.Diagnostics.Process() hangs

Hi George,

There are no windows where I need to click yes/no/next or anything
like that. I have even tried with a test.bat file. The bat file is
very simple and runs %system% ver, and returns the windows version.
This file can be succesfully invoked, if the impersonization is not
applied. But as soon as the imporsonization is turned in in the code,
this also hangs.
For me it seems like an error in the startinfo class, but what makes
me wonder is that .Net 2.0 has been released for a while and if it was
a bug in .Net framework, microsoft should have spotted that ages a
ago.

The process starts when impersonating but it seems as if it started in
idle/standby mode!

On 12 Nov., 14:16, "George Ter-Saakov" <gt-...@cardone.com> wrote:
> Does it have any dialog boxes like asking yes/no?
> If so then you will not see it and can not click button.
>
> George
>
> "Saya" <va...@hotmail.com> wrote in message
>
> news:1194860309.319364.61790@k79g2000hse.googlegro ups.com...
> Hi John,
>
> Yes I have tried the command manually, and it works fine, with the
> user that I am impersonating.
> The command is such that if the paramters are not supplied it responds
> immediately with error.
>
> On 6 Nov., 16:46, John MJ Gorter <john.gor...@gmail.com> wrote:
>
>
>
> > Did you try to mannually execute the proces with the given parameters.
> > It might be that the executing process is waiting for input....

>
> > On Tue, 06 Nov 2007 06:53:55 -0800,Saya<va...@hotmail.com> wrote:
> > >Hi Folks,

>
> > >I have now spend app. 3 days to get the below scenario to work, but
> > >can not get there!

>
> > >.Net version = 2.0.50727
> > >Windows version = Microsoft Windows [Version 5.2.3790] = Windows
> > >Server 2003

>
> > >Now I have to develop a webservice which is run on the server. The
> > >webservice will need to invoke an exe (which is a server application
> > >exe). Now this exe file needs to be exeucuted as an application user,
> > >thus I have the need of starting the process as a application user
> > >through the webservice.

>
> > >using System;
> > >using System.Web;
> > >using System.Web.Services;
> > >using System.Web.Services.Protocols;
> > >// Added
> > >using System.Diagnostics;
> > >using System.Security;
> > >using System.IO;
> > >using System.Configuration;

>
> > >[WebService(Namespace = "http://intranet.webservices.lundbeck.com/")]
> > >public class TSUsers : System.Web.Services.WebService
> > >{
> > > public TSUsers () {
> > > //Uncomment the following line if using designed components
> > > //InitializeComponent();
> > > }

>
> > > [WebMethod]
> > > public string CreateTSUser(String UserName, String UserEmail)
> > >{
> > > Process p = new Process();

>
> > > p.StartInfo.UserName =
> > >ConfigurationManager.AppSettings["TSMasterName"];
> > > p.StartInfo.Password = GetSecurePass();
> > > p.StartInfo.Domain = "hlucorp";
> > > //p.StartInfo.LoadUserProfile = true;

>
> > > p.StartInfo.FileName = @"e:\iw-home\bin\iwuseradm.exe";
> > > p.StartInfo.Arguments = "add-user hluw0447d\\tstest1";
> > > p.StartInfo.UseShellExecute = false;
> > > p.StartInfo.CreateNoWindow = true;
> > > p.StartInfo.RedirectStandardOutput = true;
> > > p.StartInfo.RedirectStandardError = true;

>
> > > try {
> > > p.Start();
> > > p.WaitForExit(1000);

>
> > > StreamReader srOutput = p.StandardOutput;
> > > StreamReader srError = p.StandardError;
> > > String CmdOutput = srOutput.ReadToEnd();
> > > String CmdError = srError.ReadToEnd();
> > > srError.Close();
> > > srOutput.Close();

>
> > > return CmdError;
> > > }
> > > catch (Exception ex) {
> > > return ex.Message;
> > > }
> > > }

>
> > > [WebMethod]
> > > private SecureString GetSecurePass() {
> > > // Different user
> > > SecureString securePass = new SecureString();
> > > String UserPass =
> > >ConfigurationManager.AppSettings["TSMasterPassword"];

>
> > > foreach (char C in UserPass) {
> > > securePass.AppendChar(C);

>
> > > }
> > > return securePass;
> > > }
> > >}

>
> > >Now I can see in the taskmanager that iwuseradm.exe has been started
> > >as the application user, but nothing happens. the whole thing just
> > >hangs!

>
> > >I have seen a lot of postings on this matter, but not one offered a
> > >solution. Different security issues are discussed etc. but no
> > >solution!

>
> > >Can anyone help ?

>
> > >Regards
> > >Saya- Skjul tekst i anførselstegn -

>
> > - Vis tekst i anførselstegn -- Skjul tekst i anførselstegn -

>
> - Vis tekst i anførselstegn -



Reply With Quote
Reply

Thread Tools


Similar Threads

Thread Thread Starter Forum Replies Last Post
System.Diagnostics.Process - Dispose? usenet DOTNET 2 12-04-2007 02:28 AM
Program started via System.Diagnostics.Process hangs usenet CSharp 3 09-25-2007 01:56 PM
Invoking System.Diagnostics.Process Start and changing the parent process usenet CSharp 2 08-30-2007 08:11 PM
Issue with System.Diagnostics.Process in a Web Service usenet DOTNET 1 08-11-2006 11:31 AM
what permissions does a windows service need to execute another process? System.Diagnostics.Process process = System.Diagnostics.Process.Start(info); just local administrator? any specific permitions? usenet XML SOAP 1 04-17-2006 04:11 PM


All times are GMT -5. The time now is 12:17 PM.