473,416 Members | 1,928 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,416 software developers and data experts.

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

Nov 6 '07 #1
5 3273
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.comwrote:
>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
Nov 6 '07 #2
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

Nov 6 '07 #3
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.comwrote:
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.comwrote:
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 -

Nov 12 '07 #4
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.comwrote in message
news:11*********************@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.comwrote:
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.comwrote:
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 -


Nov 12 '07 #5
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.comwrote:
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.comwrote in message

news:11*********************@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.comwrote:
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.comwrote:
>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 -

Nov 13 '07 #6

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

Similar topics

3
by: Horst Walter | last post by:
What I try to accomplish is to run "telnet.exe" as a process in C#. The C#-code below works with terminating commands, e.g. a "HelloWorld.exe". Since I'd like to communicate with "telnet" the...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
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...
1
by: Wojtek | last post by:
Hi, I am having problems to fetch the output of a command line program from an ASP.NET application. My code works fine in a regular Forms or command line application, but when running the same...
1
by: solex | last post by:
Hello All, Hopefully someone has run into this error. I have written a class(source below) that launches a thread to monitor the StandardOutput of a System.Diagnostics.Process, in particular I...
11
by: Nurit N | last post by:
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...
0
by: Daniel | last post by:
System.Diagnostics.Process.Start fails on windows server 2003 the process returns process.ExitCode == 0 but executing any process with System.Diagnostics.Process.Start on windows xp works fine....
5
by: =?Utf-8?B?Z215ZXJz?= | last post by:
Hello, I am attempting to start a cmd.exe process and pass several .vbs scripts (with additional parameters) and then read the output from the scripts and make "notes" in a DataTable (the...
2
by: test3 | last post by:
Hello folks, I'm using System.Diagnostics.Process to start a thirdparty program (that works perfectly when started via command line). I'm using Process.StandardOutput to get the output of the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.