Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Creating a Service using ServiceAddService


6 replies to this topic

Seany

Seany
  • Full Members
  • 64 posts

Posted 05 April 2011 - 16:16


Hi
during my install I'm creating a service as follows:

(This code is in the OnFirstUIBefore function, don't know if that is relevant?)

//********************************************
//Get the My Service Logon Info
SdLogonUserInformation ("Logon User Information for My Service", "", szAssociatedAccountName, szAssociatePassword);

//Create the Service
szServiceName = "MyService";
szServiceDisplayName = "My Service";
szServiceDescription = "This is my Service.";
szServicePathFile = TARGETDIR ^ "MyService.exe";
bStartService = FALSE;
szStartServiceArgs = "";

ServiceInitParams ();
SERVICE_IS_PARAMS.lpServiceStartName = &szAssociatedAccountName;
SERVICE_IS_PARAMS.lpPassword = &szAssociatePassword;

if (!ServiceExistsService ( szServiceName )) then
if (!ServiceAddService (szServiceName, szServiceDisplayName, szServiceDescription, szServicePathFile, bStartService, szStartServiceArgs ))then
//Service created - Do Nothing
else
//Service could not be created
MessageBox("Unable to create the Dispatcher Service", WARNING);
endif;
endif;

//***********************************

My service is created but sometimes it seems to lose the password. There is no error until you try to start the service.

If you go to the Services window via control panel and look at the properties of the service then there is something in the password field (can't tell what it is as it's hidden).
To fix the problem you just enter the correct password again and everything is fine.

I obtain the user and password using the SdLogonUserInformation dialog box and this verifies the entered information correctly so it is at some point after that the problem occurs.

Has anyone seen this or got any ideas.

Much thanks!



phood

phood
  • Full Members
  • 37 posts

Posted 05 April 2011 - 17:00

Have you tried declaring the login name and password as local string data structures (e.g., STRING szAssociatedAccountName[128])?

Seany

Seany
  • Full Members
  • 64 posts

Posted 05 April 2011 - 17:32

Hi phood

I will give that a go and see if it does the trick. It will be tomorrow before I can try it.

I will post again to let you know.

Thanks

Seany

Seany
  • Full Members
  • 64 posts

Posted 06 April 2011 - 12:22

Hi again

Declaring the strings as string[128] but:-

I think I've discovered the problem with the help of a colleague.

The problem is that the user I'm using does not have access rights to Logon As a Service.

Once I enter the password again in the service properties window the user is granted those rights and my service will start. (If I uninstall my app and install again everything works because the user no has the correct rights)

If I remove those rights the service stops working again.

Now I just have to work out if Installshield can doing something about granting the rights?

Does anyone know?

Thanks

phood

phood
  • Full Members
  • 37 posts

Posted 06 April 2011 - 14:50

Check out the Ntrights.zip utility in the link below:

http://www.installsi...s/en/isp_os.htm

Seany

Seany
  • Full Members
  • 64 posts

Posted 06 April 2011 - 15:14

Hi

Thanks again, I'll check it out

MSIYER

MSIYER
  • Full Members
  • 90 posts

Posted 06 April 2011 - 19:17

This problem can be solved by using NTrights.exe.