Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Vista Newsgroups > Vista account administration

How to use C++ to add a new local user for a service

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 03-23-2007   #1 (permalink)
Karlo Klenk
Guest


 

How to use C++ to add a new local user for a service

Hi folks!

On Vista, I can't seem to have my C++ program add a new user that is usable
for a service, starting the service fails with ERROR_BAD_USER_PROFILE

Here's how I do it:

- Add the user, same code as shown in this place:
http://support.microsoft.com/kb/196070

i.E.: adduser.exe MyServiceUser MyServicePassword

(After this, the profile dir appears in C:\Users\MyServiceUser)


- Give the user the SeServiceLogonRight privilege

(I have verified that this works using the management console)


- Register the service:

CreateService(mgr, // SCManager database
"MyService", // name of service
"Sample Service", // service name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS, // service type
SERVICE_DEMAND_START, // start type
SERVICE_ERROR_NORMAL, // error control type
path, // path to service's binary
NULL, // no load ordering group
NULL, // no tag identifier
NULL, // no dependencies
".\\MyServiceUser", // Local system account
"MyServicePassword"); // no password


- Try to start the service: net start MyService
XP: Works
Vista: Fails with 1253: ERROR_BAD_USER_PROFILE


Now if I logon this user once manually at the welcome screen
(which needs some fiddling in the user management console to allow this),
the service can be started.

Thus I conclude there's something missing beyond calling LoadUserProfile(),
but what is it?

Thanks in advance!

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
The User Profile Service service failed the logon. User Profile cannot be loaded fymjmheh Vista file management 9 1 Week Ago 03:49 AM
User Profile Service service failed the logon Koobro General Discussion 1 07-16-2008 07:56 PM
Error ! User Profile Service service failed the logon. DavidinEdmond Vista account administration 14 07-10-2008 04:33 AM
'User Profile Service service failed the logon george1dful Vista General 8 05-24-2008 01:51 PM
User Profile Service: Service Failed Logon Kinhaven Vista General 0 04-25-2007 12:04 PM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008