A
Agnes
Hi,
I posted a question earlier asking about starting a process as a different
user from windows service. I got some replies and read about this a bit
more on the web but still couldn't get it working.
The application I want to start is a console app and it also opens a win
form which contains an axWebBrowser. There is no user interaction with the
form.
I've tried creating a Process and set the username, password and domain in
the Process's StartInfo:
Process p = new Process();
p.StartInfo.FileName = "somePathToThe.EXE";
p.StartInfo.Arguments = "some arguments";
p.StartInfo.UserName = "theUser@Domain";
p.StartInfo.Password = passwordInSecureString;
p.StartInfo.UseShellExecute = false;
p.Start();
I've also tried Pinvoke the CreateProcessWithLogonW Windows API call. I
read about having to set the default desktop for console application so I
did this: startupInfo.lpDesktop = @"winsta0\default";
These 2 methods both did not work. I got this message as soon as the
process starts: The application failed to initialize properly (0xc0000142).
Click on OK to terminate the application.
If I start this application without the impersonate, it works perfectly. I
won't see the console and win form showing up but I see the expected result
when the app ends.
Only when I add in the impersonate, I get the error message every time when
the windows service tries to start my application.
Also I have a console app which does the same thing as my win service. If I
try the impersonation in the console mode, it works. Only when it runs from
win services, it gives the error.
Is there other way to do this? Or am I missing something in my code??
Thank you!!
Agnes
I posted a question earlier asking about starting a process as a different
user from windows service. I got some replies and read about this a bit
more on the web but still couldn't get it working.
The application I want to start is a console app and it also opens a win
form which contains an axWebBrowser. There is no user interaction with the
form.
I've tried creating a Process and set the username, password and domain in
the Process's StartInfo:
Process p = new Process();
p.StartInfo.FileName = "somePathToThe.EXE";
p.StartInfo.Arguments = "some arguments";
p.StartInfo.UserName = "theUser@Domain";
p.StartInfo.Password = passwordInSecureString;
p.StartInfo.UseShellExecute = false;
p.Start();
I've also tried Pinvoke the CreateProcessWithLogonW Windows API call. I
read about having to set the default desktop for console application so I
did this: startupInfo.lpDesktop = @"winsta0\default";
These 2 methods both did not work. I got this message as soon as the
process starts: The application failed to initialize properly (0xc0000142).
Click on OK to terminate the application.
If I start this application without the impersonate, it works perfectly. I
won't see the console and win form showing up but I see the expected result
when the app ends.
Only when I add in the impersonate, I get the error message every time when
the windows service tries to start my application.
Also I have a console app which does the same thing as my win service. If I
try the impersonation in the console mode, it works. Only when it runs from
win services, it gives the error.
Is there other way to do this? Or am I missing something in my code??
Thank you!!
Agnes