[RC5] Automating install

Dysart, Derek DYSD1 at Aerial1.com
Thu Jan 15 10:38:37 EST 1998


> ----------
> From: 	Jo Hermans[SMTP:Jo.Hermans at vub.ac.be]
> Reply To: 	rc5 at llamas.net
> Sent: 	Thursday, January 15, 1998 10:01 AM
> To: 	rc5 at llamas.net
> Subject: 	RE: [RC5] Automating install
> 
> 
> Wouldn't it be nice if someone posts his auto-install script on this
> list 
> :-)
> It will save all of us on NT a lot of work ...
> 
I would, but I dinked all of mine by hand (I'm only running five
clients).  I also didn't take the uninstall/install.  I copied all of
the buffers to a central place and delete all of the old clients.  Then
I copied all of the new stuff into the old directories.  Finally, since
the executable name changed, I dinked the "ImagePath" value in the
registry to read "rc5desrv" instead of "rc564srv".  Again, I only had
five client to update, if you have fifty, then Andrew Wood's script is a
mush less painful solution.

The problem of having to manually change the service's startup parameter
to "Automatic" could easily be remedied in the code.  Installing an NT
service is accomplished through the Win32 API function CreateService.
One of the parameters of this function is dwStartType.  Instead of
specifying SERVICE_DEMAND_START for this parameter, by specifying
SERVICE_AUTO_START, it will be installed and setup to start
automatically.  So the install code would look something like:

//////////////////////////////////////////////////////////////////
//	Open the Service Control Manager
//////////////////////////////////////////////////////////////////
SC_HANDLE hSCM = ::OpenSCManager( NULL, // local machine
                                  NULL, // ServicesActive database
                                  SC_MANAGER_CREATE_SERVICE);
if (!hSCM) return FALSE;

//////////////////////////////////////////////////////////////////
//	Get the executable file path
//////////////////////////////////////////////////////////////////
char szFilePath[_MAX_PATH];
::GetModuleFileName( NULL, szFilePath, sizeof( szFilePath ) );

//////////////////////////////////////////////////////////////////
// Create the service
//////////////////////////////////////////////////////////////////
SC_HANDLE hService = ::CreateService(hSCM,
                                     "RC5 Service Client", //Or similar
                                     "RC5 Service Client", //Or similar
                                     SERVICE_ALL_ACCESS,
                                     SERVICE_WIN32_OWN_PROCESS,
                                     SERVICE_AUTO_START, // auto start 
                                     SERVICE_ERROR_NORMAL,
                                     szFilePath,
                                     NULL,
                                     NULL,
                                     NULL,
                                     NULL,
                                     NULL);
if ( !hService ) {
    ::CloseServiceHandle( hSCM );
    return FALSE;
}

Hopefully, whoever maintains the NT service is listening in.


--
To unsubcribe, send 'unsubscribe rc5' to majordomo at lists.distributed.net
rc5-digest subscribers replace rc5 with rc5-digest



More information about the rc5 mailing list