473,421 Members | 1,615 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,421 software developers and data experts.

Start User Process from Local System Service

Here's my problem.

I have an NT service (really a .NET service) running as local system.
I have a .NET form running on the user account. The form and the
service communicate via an IPC Channel so the form can control the
service and do various things. Both applications share the same set
of dlls.

When performing an update of some of the dlls, both the service and
the form must be shut down (that's just how it's implemented -- didn't
want to deal with unloading app domains). The update is performed by
a separate program that is run by the service, so the update process
is also running under Local System. Since the update process shuts
down the form process, I want it to restart the form process when the
update completes. The problem is that the form process restarts as
Local System. I want it to be under the user account that originally
started it.

There is a .NET method to start a process as another user --
Process.Start() with a ProcessStartInfo structure that specifies the
username and password of the user account. However, that cannot work
because I can't specify the password. So I've resorted to getting the
user handle via Interop and running StartProcessAsUser giving it the
user handle acquired from OpenProcessToken. I get Access Denied.

Any other ways to launch user process from local system without having
the password?

May 7 '07 #1
3 11223
Unfortunately not, as it would cause a massive security hole by allowing
this. If it was allowed, then you could launch any program under any user
account without a password?

You probably have to have some sort of monitor process that runs
alongside your own with the singular purpose of receiving an update from
your service (or your service's update process) notifying it that the update
is complete, and then restarting your app.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SugarDaddy" <er*********@gmail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
Here's my problem.

I have an NT service (really a .NET service) running as local system.
I have a .NET form running on the user account. The form and the
service communicate via an IPC Channel so the form can control the
service and do various things. Both applications share the same set
of dlls.

When performing an update of some of the dlls, both the service and
the form must be shut down (that's just how it's implemented -- didn't
want to deal with unloading app domains). The update is performed by
a separate program that is run by the service, so the update process
is also running under Local System. Since the update process shuts
down the form process, I want it to restart the form process when the
update completes. The problem is that the form process restarts as
Local System. I want it to be under the user account that originally
started it.

There is a .NET method to start a process as another user --
Process.Start() with a ProcessStartInfo structure that specifies the
username and password of the user account. However, that cannot work
because I can't specify the password. So I've resorted to getting the
user handle via Interop and running StartProcessAsUser giving it the
user handle acquired from OpenProcessToken. I get Access Denied.

Any other ways to launch user process from local system without having
the password?

May 7 '07 #2
On May 7, 2:03 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Unfortunately not, as it would cause a massive security hole by allowing
this. If it was allowed, then you could launch any program under any user
account without a password?

You probably have to have some sort of monitor process that runs
alongside your own with the singular purpose of receiving an update from
your service (or your service's update process) notifying it that the update
is complete, and then restarting your app.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
Thank you for the quick reply. I figured that it would be a security
risk, but I thought that maybe there was some way of being able to
restart a process that was already running. Your proposed solution is
actually what I was considering. I just figured before I go through
the work of implementing it with the IPC channel and all that it would
be worth finding out if the easier way was possible.

Thanks.

-eric
May 7 '07 #3
Thought I'd post a follow-up...

As per your suggestion, Nicholas, I implemented this like so.

When the Service app running as Local System receives an update
request and executes the update process (also running as Local
System), the update process uses the Form application's IPC Server
Channel to notify the form to shut down. The Form extracts from its
resources a small console application that waits a certain amount of
time before relaunching the Form app then shuts down. After the time
passes (allowing the update to complete), the Form is relaunched. All
in all, not a bad solution. A better solution would actually notify
the "relauncher" app when the update completed rather than waiting a
constant amount of time. But since the update is basically just
copying fiiles, there's really not much more than a few milliseconds
in variability between clients and the constant amount of time will
suffice.

Anyway, thanks again.

May 8 '07 #4

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

Similar topics

12
by: GTi | last post by:
I have small program that always must be running when a user is logged on. Since users can close this program I must create a program that always check if this program is running. So I created a...
11
by: Kirk | last post by:
The following C# web service works fine until you uncomment the lines setting UserName and Password. Then the process starts as the specified user, but hangs in a suspended state. In fact, any...
0
by: Kirk | last post by:
The following C# web service works fine until you uncomment the lines setting UserName and Password. Then, Process.Start throws an Access is Denied Exception. This is with .NET 2.0, of course...
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...
6
by: uuyytt | last post by:
I have a Windows service from which I want to start Internet Explorer with a particular URL as an argument. I don't know why my code (shown below) doesn't work. I know that IExplore.exe starts as I...
3
by: SR | last post by:
I have a requirement from a customer to run some command line applications from a service. I have most of my service coded and I've come across an issue with the important part of the application,...
4
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
0
by: =?Utf-8?B?SmFzb24gTGluZA==?= | last post by:
Hi, I have a WCF Service hosted by a Windows Service using Impersonation. The impersonation seems to be configured correctly, in that Thread.CurrentPrinipal is the user calling the service, not the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
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
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...
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...

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.