473,799 Members | 2,727 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 1132

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

Similar topics

1
3435
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
2390
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
9365
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
1981
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
9550
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10495
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10032
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
9085
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...
0
6811
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
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
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.