473,408 Members | 2,888 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,408 software developers and data experts.

starting process with alternate credentials causes application error

I am trying to get my .net page to run a simple batch file on my IIS
server. I want it to run with specified credentials. It appears to
start the program cmd.exe as the correct user (shows up in the task
mgr) but it just hangs there and will never finish. Looking in the
event logs I see this:

Application popup: cmd.exe - Application Error : The application
failed to initialize properly (0xc0000142). Click on OK to terminate
the application.

I have no idea why it is hanging like that, can someone help me? Here
is my code:
SecureString pwd = new SecureString();
pwd.Clear();
pwd.AppendChar('1');
pwd.AppendChar('2');
pwd.AppendChar('3');
pwd.AppendChar('4');
pwd.AppendChar('5');
pwd.AppendChar('6');
pwd.AppendChar('7');
pwd.AppendChar('8');
pwd.AppendChar('9');

ProcessStartInfo startInfo = null;
Process batchProcess = null;

startInfo = new ProcessStartInfo();
startInfo.Domain = "somedomain";
startInfo.UserName = "Domainuser";
startInfo.Password = pwd;
startInfo.WorkingDirectory = @"C:\";
startInfo.FileName = "cmd.exe";
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = true;
startInfo.Arguments = @"/c c:\test.bat";
startInfo.ErrorDialog = false;
batchProcess = new Process();
batchProcess.StartInfo = startInfo;
batchProcess.Start();

System.IO.StreamReader myProcessOut = batchProcess.StandardOutput;
string s = myProcessOut.ReadToEnd();
myProcessOut.Close();
batchProcess.WaitForExit(1000);
if (!batchProcess.HasExited)
batchProcess.Kill();

....Jamie

Jun 22 '07 #1
4 7851
Is it possible to log in interactively as this user and check to see if
you can run the program under that user account? Also, if you impersonate
that user for the page (using web.config, or the WindowsIdentity class),
does it work then?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"DubSport" <ja**************@cmgl.cawrote in message
news:11*********************@q19g2000prn.googlegro ups.com...
>I am trying to get my .net page to run a simple batch file on my IIS
server. I want it to run with specified credentials. It appears to
start the program cmd.exe as the correct user (shows up in the task
mgr) but it just hangs there and will never finish. Looking in the
event logs I see this:

Application popup: cmd.exe - Application Error : The application
failed to initialize properly (0xc0000142). Click on OK to terminate
the application.

I have no idea why it is hanging like that, can someone help me? Here
is my code:
SecureString pwd = new SecureString();
pwd.Clear();
pwd.AppendChar('1');
pwd.AppendChar('2');
pwd.AppendChar('3');
pwd.AppendChar('4');
pwd.AppendChar('5');
pwd.AppendChar('6');
pwd.AppendChar('7');
pwd.AppendChar('8');
pwd.AppendChar('9');

ProcessStartInfo startInfo = null;
Process batchProcess = null;

startInfo = new ProcessStartInfo();
startInfo.Domain = "somedomain";
startInfo.UserName = "Domainuser";
startInfo.Password = pwd;
startInfo.WorkingDirectory = @"C:\";
startInfo.FileName = "cmd.exe";
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = true;
startInfo.Arguments = @"/c c:\test.bat";
startInfo.ErrorDialog = false;
batchProcess = new Process();
batchProcess.StartInfo = startInfo;
batchProcess.Start();

System.IO.StreamReader myProcessOut = batchProcess.StandardOutput;
string s = myProcessOut.ReadToEnd();
myProcessOut.Close();
batchProcess.WaitForExit(1000);
if (!batchProcess.HasExited)
batchProcess.Kill();

...Jamie
Jun 23 '07 #2
"DubSport" <ja**************@cmgl.cawrote in message
news:11*********************@q19g2000prn.googlegro ups.com...
>I am trying to get my .net page to run a simple batch file on my IIS
server. I want it to run with specified credentials. It appears to
start the program cmd.exe as the correct user (shows up in the task
mgr) but it just hangs there and will never finish. Looking in the
event logs I see this:

Application popup: cmd.exe - Application Error : The application
failed to initialize properly (0xc0000142). Click on OK to terminate
the application.

I have no idea why it is hanging like that, can someone help me? Here
is my code:
SecureString pwd = new SecureString();
pwd.Clear();
pwd.AppendChar('1');
pwd.AppendChar('2');
pwd.AppendChar('3');
pwd.AppendChar('4');
pwd.AppendChar('5');
pwd.AppendChar('6');
pwd.AppendChar('7');
pwd.AppendChar('8');
pwd.AppendChar('9');

ProcessStartInfo startInfo = null;
Process batchProcess = null;

startInfo = new ProcessStartInfo();
startInfo.Domain = "somedomain";
startInfo.UserName = "Domainuser";
startInfo.Password = pwd;
startInfo.WorkingDirectory = @"C:\";
startInfo.FileName = "cmd.exe";
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = true;
startInfo.Arguments = @"/c c:\test.bat";
startInfo.ErrorDialog = false;
batchProcess = new Process();
batchProcess.StartInfo = startInfo;
batchProcess.Start();

System.IO.StreamReader myProcessOut = batchProcess.StandardOutput;
string s = myProcessOut.ReadToEnd();
myProcessOut.Close();
batchProcess.WaitForExit(1000);
if (!batchProcess.HasExited)
batchProcess.Kill();

...Jamie

The application is hanging because there is a dialog box (invisible!)
waiting for a user action "..Click on OK to terminate...".
What application are you trying to start from test.bat?

Willy.

Jun 24 '07 #3
I am able to log in as the specified user and run the .bat file no
problem, it requires no user input at all, and exits automatically.
The .bat file uploads a PDF to a sharepoint site. The specified user
has all necessary permissions from start to finish on files/folders
and sharepoint sites. I have even tried running a very simple dos
command "ipconfig" that requires no user input and same thing, it just
hangs. Is it some sort of security thing with Windows 2003 server
SP2?

I have also tried turning on impersonation in the web.config and also
looked at WindowsIdentity class, neither make a difference.
Anything else you can suggest?

....Jamie

Jun 25 '07 #4
"DubSport" <ja**************@cmgl.cawrote in message
news:11**********************@m37g2000prh.googlegr oups.com...
>I am able to log in as the specified user and run the .bat file no
problem, it requires no user input at all, and exits automatically.
The .bat file uploads a PDF to a sharepoint site. The specified user
has all necessary permissions from start to finish on files/folders
and sharepoint sites. I have even tried running a very simple dos
command "ipconfig" that requires no user input and same thing, it just
hangs. Is it some sort of security thing with Windows 2003 server
SP2?

I have also tried turning on impersonation in the web.config and also
looked at WindowsIdentity class, neither make a difference.
Anything else you can suggest?

...Jamie

My guess is that you are running asp.net in the SYSTEM account. Both W2K3
and XP SP2 don't allow you to spawn another process with alternate
credentials when launched from the SYSTEM logon session, you'll need to run
your service (asp.net worker) under the "NetworkService "service account .

Willy.

Jun 25 '07 #5

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

Similar topics

12
by: serge calderara | last post by:
Dear all, I have an application which is suppose to start another executable process. As soon as that process is running, I need to retrive its handle. The problem of the particular process I am...
2
by: Ale | last post by:
I try to start a program with process.start method. It normally starts but no window is displayed, i only see the application process running on the taskmanager. I think the process is executed...
1
by: Nusret Bajric | last post by:
Hello, I have a problem with starting a COM application from my ASP.NET application on the server machine. I get an error with a message permission denied during creation of COM object. If I...
3
by: Jørn A. | last post by:
I'm working on a web based user interface for a job scheduling system (running scripts). The system is using a non-windows scheduler software, but it's installed and running as a windows...
3
by: Christopher | last post by:
One of our ASP.NET Pages is starting a new Process using the Process object. When the process starts, it is started under the ASPNET User. We tried editing the web.config file and the...
8
by: Mike | last post by:
Inside a HttpHandler I'm trying to spawn an EXE (console app). Although it shows up in the process list, it doesn't seem to do anything. (And even if I specify ProcessWindowStyle.Normal, it doesn't...
6
by: ludwig.stuyck | last post by:
Hi all, I need to start an executable from within a windows service. I tried the following code in the windows service: ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName =...
0
by: Mark Henry | last post by:
I wrote a Desktop class for manipulating desktops and window stations. The class is being used by a service for starting applications on the interactive desktop (the service cannot run as Local...
0
by: Lloydm | last post by:
Hi all. The cisco vpn software has a built in "application launcher" function which I cannot get to work. As a work around I created a batch file which calls a vb script doing the job perfectly! I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.