Real Geek Forums  

Go Back   Real Geek Forums > Archives > Operating Systems > Windows Vista > Windows Vista Administration

Notices

Reply

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

 

LinkBack Thread Tools Display Modes
Old 03-23-2007, 09:52 AM   #1 (permalink)
Default 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!
Karlo Klenk
Guest
 
Posts: n/a
Reply With Quote  
Reply

Tags
None

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
User index service on Limited User Account mad Windows XP Configuration & Management 0 11-03-2004 11:18 PM
Make local computer user domain user too? Ken Very Big Liar Windows XP Help & Support 1 10-02-2003 02:16 AM
Internet Authentication Service (IAS) server only supports local user accounts Oliver Windows XP Work Remotely 0 07-17-2003 08:54 AM
SVCHOST.EXE LOCAL SERVICE Jim Rogers Windows XP Performance & Maintenance 5 07-10-2003 03:36 AM
Automating User Local User Account Creation DPMJR Windows XP Setup 0 07-09-2003 01:59 AM


All times are GMT. The time now is 12:22 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright © 2005 - 2007 RealGeek.com. All rights reserved.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48