473,468 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Diagnostics.Process.Start as another user from ASP.NET 2.0

Here is what I am trying to get to:
I have a console exe that grabs information from the network and writes to
an XML file on the website that web pages then render information from. The
console will be scheduled to run through windows scheduler. However,
sometimes a user may need the information sooner so he/she needs to kick off
the console exe.

The new Process.Start looked teasingly simple. It had a username/password on
the start info. Seemed simple enough.

We created a user with Read/Write/Execute to the folder of the EXE and the
destination folder of the XML files. Both folders are underneath the website.
The network shares are accessable through read-only shares to Everyone.

I get this error: "The application failed to initialize properly
(0xc0000142). Click on OK to terminate the application. when executing it
from ASP.NET.

The dev machine is XP Pro with IIS 5.1 using the default user.

I went so far as to create an empty .NET 2.0 console exe and we get the same
error.

We've logged in to XP as this other credential and can run both EXEs with no
error.

public static void RefreshContent(string filePath)
{
Process processor = new Process();
processor.StartInfo.FileName = filePath;
processor.StartInfo.Arguments = "/q"; //quiet mode
processor.StartInfo.CreateNoWindow = true;
processor.StartInfo.WorkingDirectory =
System.IO.Path.GetDirectoryName(filePath);
processor.StartInfo.UseShellExecute = false;
processor.StartInfo.LoadUserProfile = false; //true also failed.
processor.StartInfo.UserName = "RefreshContentFromWeb";
SecureString password = MakeSecureString("0a8fsud");
password.MakeReadOnly();
processor.StartInfo.Password = password;
processor.Start();

processor.WaitForExit(1000 * 60 * 5); //5 minutes.
}

private static SecureString MakeSecureString(string passwordString)
{
SecureString password = new SecureString();
foreach (char x in passwordString)
{
password.AppendChar(x);
}
password.MakeReadOnly();
return password;
}
May 7 '07 #1
4 5979
Hi Noremac,

For the Process.Start with a specific user, there exists some problem when
executing in ASP.NET application context as I've also met some former
issues discussing on this problem. Currently, the recommended means for
launch a process running under a specific user account is to call unmanaged
API through Pinvoke. Here is a former thread you can reference:

#Run app as specified user from ASP.NET 2.0 Options
http://groups.google.com/group/micro...rk.aspnet/brow
se_thread/thread/51584884d09edfa5/bbfcbd72a6957085

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


May 8 '07 #2
That's funny! I was unsuccessful in getting similar code like the post you
provided to work with ASP.NET 1.1 and then I saw references to the
username/password in 2.0 and so I upgraded my code.

Oh well, perhaps I can get the pinvoke unmanaged stuff to work this time
around knowing there is no other way.

Thanks for setting me back on the right path Steven.

"Steven Cheng[MSFT]" wrote:
Hi Noremac,

For the Process.Start with a specific user, there exists some problem when
executing in ASP.NET application context as I've also met some former
issues discussing on this problem. Currently, the recommended means for
launch a process running under a specific user account is to call unmanaged
API through Pinvoke. Here is a former thread you can reference:

#Run app as specified user from ASP.NET 2.0 Options
http://groups.google.com/group/micro...rk.aspnet/brow
se_thread/thread/51584884d09edfa5/bbfcbd72a6957085

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


May 8 '07 #3
Hi Noremac,

I still keep some test projects that contains some code using pinvoke to
call win32 API(createprocessAsUser). If you need, just ping me (through the
email in my signature and remove "online" in it) and I will send you the
test project which you can reference.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

May 9 '07 #4
Hi Noremac,

Any further progress on this? If you need the test project(about using
pinvoke to create new process under specific user), please feel free to
ping me (at "stcheng" + "@microsoft.com").

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

May 14 '07 #5

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

Similar topics

0
by: Brad Shook | last post by:
Ok here is what I a trying to do. I am trying to emulate an operator having to do repetitive tasks on a 3rd party program. Here is what I am doing so far. It works. Start Code Dim myProcess As...
5
by: toby | last post by:
Can any one help? I'm trying to use System.Diagnostics.Process.Start to open legacy MS access aplications (ade and mdb files) and vb 6 .exe's using asp.net. There is something confusing going on?!?...
1
by: ginee lee via .NET 247 | last post by:
(Type your message here) hi all, It seems that the arguments of System.Diagnostics.Process.Start()can only be the absolute path. The args can not be like".\abc\efg.exe" or "..\abc\efg.exe". While i...
5
by: mg | last post by:
The following .exe and its parameters work correctly from the command prompt (it prints x.pdf without prompting the user. acrord32.exe /t "c:\exportfiles\x.pdf" "HP LaserJet 3300 Series PCL 6"...
2
by: andreas | last post by:
hi, In windows xp in the start launch menu when i put notepad "c:\test.txt" i get notepad with test.txt in it. in vb.net when i state system.diagnostics.process.start("notepad.exe" i get...
2
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....
1
by: Daniel | last post by:
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...
0
by: Daniel | last post by:
C# windows service freezes on System.Diagnostics.Process.Start(info) When I launch PSCP from a C# windows service and launch pscp 0.53 there are no issues. but when I use C# windows service to...
0
by: Dominic | last post by:
Every thing work fine when I am not starting process as another user. When I am starting process as another user, the authentication is working (I can see it in my workstation security log), but...
6
by: kimiraikkonen | last post by:
Hello, I want to ask this: If i do: System.Diagnostics.Process.Start("c:\lame", "--preset standard c:\blabla.wav c:\blabla.mp3") it works. But i don't want this. I want my 2 textboxes must...
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...
1
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.