473,811 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CreateProcessWi thLogonW

Hello,

I posted this in the aspnet.security group a few days ago but haven't
received any feedback, so I thought I would try this group. Apologies if
this is the wrong place.
I am developing an ASP.NET application that allows users to enter data using
web forms, then run an EXE when they click the appropriate button. The EXE
needs certain security rights not available to the ASPNET user.
After playing around with impersonation, I found that even using
impersonation, the child process will be run as ASPNET. So after more
digging, I found the API call CreateProcessWi thLogonW(). I'm using the RunAs
class from http://www.codeproject.com/csharp/RunAs.asp and this did the trick
(after much persuasion) and everything is now working beautifully...a lmost.
When the process created with CreateProcessWi thLogonW ends, we need to get
the exit code of the program. Using the System.Diagnost ics.Process class, I
was previously able to do so as such:
myProcess.Start ();
myProcess.WaitF orExit();
return myProcess.ExitC ode;
Unfortunately, starting the process using CreateProcessWi thLogonW prevents
me from getting the exit code; I get an access denied error. Which makes
sense, since a user with stronger rights created the process, not the ASPNET
account. I've tried impersonating the same user with which I create the
process, but still get the same error.
So my question is: does anyone know of a way to get the exit code of the
process created with CreateProcessWi thLogonW() in an ASP.NET application?
A sample code listing follows:
dim proc as System.Diagnost ics.Process
proc = VastAbyss.RunAs .StartProcess
( "username", "domain", "password", "c:\test\myprog ram.exe" )
'Here is where the trouble starts; the call to WaitForExit seems to
'succeed, but an exception is thrown on the proc.ExitCode call.
proc.WaitForExi t()
return proc.ExitCode

I've also tried using the API call GetExitCodeProc ess(); it will return the
STILL_ACTIVE constant until the process terminates, but then appears to throw
an exception instead of getting the exit code. Strangely, even though I have
the call inside a try-catch block, it is not being caught there.

Any insights would be greatly appreciated.

Nov 19 '05 #1
0 1133

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

Similar topics

1
3436
by: Arne | last post by:
Hi, I'm working on an asp.net application that reads a users username and password, and starts a process with the username read. The problem is that the program returns value 2(ERROR_FILE_NOT_FOUND). Here's my code: public class Class1 {
2
2391
by: jerry | last post by:
I'm trying to run an application under another user within a winform app writen in C#. I have tried a number of different things, but it seems that the CreateProcessWithLogonW function should work to do what I need to do. This appears to work just fine in Windows 2000 and XP with service pack 1, but it doesn't work with XP service pack 2 installed. I'm sure it's one of the "Enhanced security features" of service pack 2, but I can't...
1
3391
by: Alireza Haghshenass | last post by:
Dear All I am already using CreateProcessWithLogonW() to create a process under an specific user but when i try to load that program again from an xml file I get an error like this. File not found. I mean the executable file is not recognized. until I open the open dialog and go to the folder of the program and this time the program starts the saved program. Do you know what is the problem? This problem does not exist for the executable...
2
9366
by: Bilal Dinc | last post by:
Hey, I have a question concerning the CreateProcessWithLogonW function imported from the advapi32 dll. For some reason I cant get the appName and cmdLine paramters to work together. For example, I'm trying to use the Perforce command line utility (p4.exe) to download some files to the local computer. So I set appName="p4.exe" and cmdLine="print -o \"c:\\file.txt\" -q \"//depot/files/file.txt\"". So then I call...
10
5407
by: David Davidson | last post by:
I am attempting to use CreateProcessWithLogonW from the server-side code of a web page (yes, I want to create a process on the server) and not having much luck. I am attempting to run VPScan, an unsupported command-line virus scanner from Symantec, to check an uploaded file for viruses. At first, I wrapped VPScan with a DLL and ran it as a COM+ component and found that it would work only when someone was logged on and it was set to run...
6
1982
by: Matthew Wieder | last post by:
I have an ASPNET app that is running as the ASPNET machine user. It makes a call to the API CreateProcessWithLogonW. On Windows XP it executes without a problem, but on Windows 2000, I get an "Access is Denied" exception. I tried adding the ASPNET account to all the items in the "User Rights Assignment" list but to no avail. The only think that work was adding the ASPNET account to the local admin group; then it executed perfectly. ...
3
2329
by: Benjamin Bittner | last post by:
Hallo NG, I have problems with calling the CreateProcessWithLogonW() function. I tried converting an VB6 example (http://support.microsoft.com/default.aspx?scid=kb;en-us;285879) and some snippets i found around the web. but i cant get it to work. It tries to start the application, but it fails. In my eventlog i can see a new info message, everytime i execute my code. i try to translate it, cause i have a german windows installed, so it...
1
2088
by: ashu.nitc | last post by:
Hi, I am trying to create a process with the API: CreateProcessWithLogonW. The process (say, CMD.EXE) which gets created doesnt have the environment variables which I have explicitly passed into it as the parameter. The same environment block works for CreateProcessAsUser, but doesnt give me the same results when used with CreateProcessWithLogonW(). The difference in the list
1
4555
by: ashu.nitc | last post by:
Hi , I am trying to create process using CreateProcessWithLogonW() API. This works fine on Win2000 and NT, but in Vista it gives a UAC popup before the process (say, notepad, calc, etc) kicks off. This is the sample program that I am compiling on .NET /* START OF PROGRAM */
2
2897
by: None | last post by:
What's the difference between StartInteractiveClientProcess in http://msdn.microsoft.com/en-us/library/aa379608(VS.85).aspx, and CreateProcessWithLogonW? http://msdn.microsoft.com/en-us/library/ms682431(VS.85).aspx They look different, e.g. it seems that CreateProcessWithLogonW requires that the user account must be allowed to log on interactively.
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10408
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10137
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9211
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7673
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3874
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3026
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.