views:

151

answers:

4

I built a testing service which writes a message to a local file. I noticed the "Owner" property of the file is always "Administrator" which is same when using "Local System" account. But I have changed the "Log on as" setting to my personal account in service manager.

What should I do to make the service work on a specified account?

A: 

I am not sure how to do it, but you should also set the user to "Run as a service" option. check the MSDN API for details

Ram
A: 

The "Log on as" setting should do what you want.

Could it be that you haven't created the file after you changed the logon account? If you overwrite the file, the owner will probably not change.

I'm not sure if it is advisable to log the service on as a regular user. The user will need the "log on as a service" right. You might have that if you're an administrator, but a regular user might not.

Tor Haugen
I deleted the file, I believe the file is newly created by the service.
trudger
A: 

You could do this by creating a WMI script to set up the Service settings.

You cannot, as far as I know, hardcode the user the service will use automatically.

Jon
No, I don't want to change the service settings. The service is already running by my personal account. What I'm asking is that although the service is running under my personal account, the files it generated is 'owned' by "administrator". You can saw it at "File Properties->Detail->Owner". I don't understand why the owner isn't my account.
trudger
A: 

What should I do to make the service work on a specified account?

You do exactly the same, but specify that specific account in service control manager.

Or do you mean that the service will only be running for a specific user?

Magnus Skog