Start application from service

T

Two Toed

Hello everyone,

I am writing a Windows service (in VB.net) that requires the assistance of a
separate "helper" executable. I would like for the service to be able to
automatically start the helper exe when the service starts, and likewise, to
be able to stop the helper exe when the service stops. The catch is that the
helper exe must run under the account of the current user and not under
Local System or Local Service.

I know I can do the following to start the helper in OnStart:

Process1.StartInfo.FileName = "C:\windows\notepad.exe" ' Example exe
Process1.StartInfo.UserName = My.User.Name
Process1.StartInfo.CreateNoWindow = False
Process1.Start()

But notepad.exe will run under the same account as the service (and not
under My.User.Name). I can't add Process1.StartInfo.Password to that because
I don't know the user's password.

Any suggestions/comments as to how I may be able to accomplish this are
appreciated!
 
W

Willy Denoyette [MVP]

You can't do this as long as you don't have the users password.

Willy.
 
G

Guest

Do you have any suggestions as to how I could accomplish the same goal most
effectively? Or is my only alternative to put the "helper" in the Run section
of the registry so it is running while the service is running?
 
P

Peter Huang [MSFT]

Hi

If you want the Process to run certain user's credential, you need the
username/password pair.
Also can you describle your scenario more detailed? You can run the service
under your username account if you have the your password.
Did that works for you?

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Thanks for the suggestion. I will try that.

The service needs to use Active Accessibility objects to interact with the
desktop (and I know it cannot) which is why it needs the helper program.
 
P

Peter Huang [MSFT]

Hi

Also we did not recommend to open a window in the interactive desktop from
a service.
Warning There is a significant security risk for any service that opens a
window on the interactive desktop. By opening a desktop window, a service
makes itself vulnerable to attack from the logged-on user, whose
application could send malicious messages to the service's desktop window
and affect its ability to function.

I think it would better start the client(the app is going to be started
from service) from TaskSchedule or Run and then use IPC(e.g. TCP/IP) to
interactive client with Service.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top