*** empty log message ***

svn path=/trunk/boinc/; revision=4532
This commit is contained in:
Rom Walton 2004-11-12 18:11:31 +00:00
parent 0686b3b1c3
commit 8c57c534da
6 changed files with 23 additions and 218 deletions

View File

@ -19288,4 +19288,14 @@ Rom 12 Nov 2004
BOINC.ism
win_build/installerv2/redist/Windows/
BOINC.vbs
Rom 12 Nov 2004
- On Windows, BOINC should not prompt for a project if non exist.
- On Windows, remove the -install and -uninstall from the commandline since the
installer now takes care of it.
client/
main.C
cd_cmdline.C
client/win/
win_service.cpp

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
@ -35,10 +37,6 @@ static void print_options(char* prog) {
printf(
"Usage: %s [options]\n"
" -version show version info\n"
#if defined(_WIN32) && defined(_CONSOLE)
" -install install boinc as a Windows Service\n"
" -uninstall uninstall boinc as a Windows Service\n"
#endif
" -exit_when_idle Get/process/report work, then exit\n"
" -show_projects show attached projects\n"
" -return_results_immediately contact server when have results\n"

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
@ -141,6 +143,7 @@ void show_message(PROJECT *p, char* msg, int priority) {
// and create an account file
//
int add_new_project() {
#ifndef WIN32
PROJECT project;
printf("Enter the URL of the project: ");
@ -154,6 +157,9 @@ int add_new_project() {
project.tentative = true;
return project.write_account_file();
#else
return 0;
#endif
}
#ifdef WIN32
@ -321,11 +327,7 @@ int main(int argc, char** argv) {
};
if ( (argc > 1) && ((*argv[1] == '-') || (*argv[1] == '/')) ) {
if ( _stricmp( "install", argv[1]+1 ) == 0 ) {
CmdInstallService();
} else if ( _stricmp( "uninstall", argv[1]+1 ) == 0 ) {
CmdUninstallService();
} else if ( _stricmp( "win_service", argv[1]+1 ) == 0 ) {
if ( _stricmp( "win_service", argv[1]+1 ) == 0 ) {
// allow the system to know it is running as a Windows service
// and adjust it's diagnostics schemes accordingly.

View File

@ -1,3 +1,5 @@
// $Id$
//
// The contents of this file are subject to the BOINC Public License
// Version 1.0 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
@ -35,10 +37,6 @@ DWORD dwErr = 0;
TCHAR szErr[1024];
// Define API's that are going to be used through LoadLibrary calls.
typedef WINADVAPI BOOL (WINAPI *PROCCHANGESERVICECONFIG2)(SC_HANDLE, DWORD, LPCVOID);
//
// FUNCTION: service_main
//
@ -347,204 +345,6 @@ VOID LogEventInfoMessage(LPTSTR lpszMsg)
}
}
//
// FUNCTION: CmdInstallService()
//
// PURPOSE: Installs the service
//
// PARAMETERS:
// none
//
// RETURN VALUE:
// none
//
// COMMENTS:
//
void CmdInstallService()
{
SC_HANDLE schService;
SC_HANDLE schSCManager;
HINSTANCE hinstAdvAPI32;
PROCCHANGESERVICECONFIG2 ProcChangeServiceConfig2;
TCHAR szPath[512];
if ( GetModuleFileName( NULL, szPath, 512 ) == 0 )
{
_tprintf(TEXT("Unable to install %s - %s\n"), TEXT(SZSERVICEDISPLAYNAME), windows_error_string(szErr, (sizeof(szErr)/sizeof(TCHAR))));
return;
}
// Append the -win_service option to the commandline.
strcat(szPath, TEXT(" -win_service"));
schSCManager = OpenSCManager(
NULL, // machine (NULL == local)
NULL, // database (NULL == default)
SC_MANAGER_ALL_ACCESS // access required
);
if ( schSCManager )
{
// Attempt to install the service with the Network Service account.
schService = CreateService(
schSCManager, // SCManager database
TEXT(SZSERVICENAME), // name of service
TEXT(SZSERVICEDISPLAYNAME), // name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS, // service type
SERVICE_AUTO_START, // start type
SERVICE_ERROR_NORMAL, // error control type
szPath, // service's binary
NULL, // no load ordering group
NULL, // no tag identifier
NULL, // dependencies
TEXT("NT AUTHORITY\\NetworkService"), // NetworkService account
NULL); // no password
// If we couldn't install the service with the Network Service account, switch
// to LocalSystem.
if ( (schService == NULL) && (GetLastError() == ERROR_INVALID_SERVICE_ACCOUNT) )
{
schService = CreateService(
schSCManager, // SCManager database
TEXT(SZSERVICENAME), // name of service
TEXT(SZSERVICEDISPLAYNAME), // name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS, // service type
SERVICE_AUTO_START, // start type
SERVICE_ERROR_NORMAL, // error control type
szPath, // service's binary
NULL, // no load ordering group
NULL, // no tag identifier
NULL, // dependencies
NULL, // LocalSystem account
NULL); // no password
}
if ( schService )
{
_tprintf(TEXT("%s installed.\n"), TEXT(SZSERVICEDISPLAYNAME) );
SERVICE_DESCRIPTION sdDescription;
sdDescription.lpDescription = TEXT(SZSERVICEDESCRIPTION);
hinstAdvAPI32 = LoadLibrary("ADVAPI32");
// If the handle is valid, try to get the function address.
if ( NULL != hinstAdvAPI32 )
{
#ifdef _UNICODE
ProcChangeServiceConfig2 = (PROCCHANGESERVICECONFIG2)GetProcAddress(
hinstAdvAPI32,
TEXT("ChangeServiceConfig2W")
);
#else
ProcChangeServiceConfig2 = (PROCCHANGESERVICECONFIG2)GetProcAddress(
hinstAdvAPI32,
TEXT("ChangeServiceConfig2A")
);
#endif
// If the function address is valid, call the function.
if ( NULL != ProcChangeServiceConfig2 )
{
if ( ProcChangeServiceConfig2(schService, SERVICE_CONFIG_DESCRIPTION, &sdDescription) ){
_tprintf(TEXT("%s service description installed.\n"), TEXT(SZSERVICEDISPLAYNAME) );
} else {
_tprintf(TEXT("ChangeServiceConfig2 failed - %s\n"), windows_error_string(szErr, (sizeof(szErr)/sizeof(TCHAR))));
}
}
// Free the DLL module
FreeLibrary( hinstAdvAPI32 );
}
CloseServiceHandle(schService);
}
else
{
_tprintf(TEXT("CreateService failed - %s\n"), windows_error_string(szErr, (sizeof(szErr)/sizeof(TCHAR))));
}
CloseServiceHandle(schSCManager);
}
else
_tprintf(TEXT("OpenSCManager failed - %s\n"), windows_error_string(szErr, (sizeof(szErr)/sizeof(TCHAR))));
}
//
// FUNCTION: CmdUninstallService()
//
// PURPOSE: Stops and removes the service
//
// PARAMETERS:
// none
//
// RETURN VALUE:
// none
//
// COMMENTS:
//
void CmdUninstallService()
{
SC_HANDLE schService;
SC_HANDLE schSCManager;
schSCManager = OpenSCManager(
NULL, // machine (NULL == local)
NULL, // database (NULL == default)
SC_MANAGER_ALL_ACCESS // access required
);
if ( schSCManager )
{
schService = OpenService(schSCManager, TEXT(SZSERVICENAME), SERVICE_ALL_ACCESS);
if (schService)
{
// try to stop the service
if ( ControlService( schService, SERVICE_CONTROL_STOP, &ssStatus ) )
{
_tprintf(TEXT("Stopping %s."), TEXT(SZSERVICEDISPLAYNAME));
Sleep( 1000 );
while( QueryServiceStatus( schService, &ssStatus ) )
{
if ( ssStatus.dwCurrentState == SERVICE_STOP_PENDING )
{
_tprintf(TEXT("."));
Sleep( 1000 );
}
else
break;
}
if ( ssStatus.dwCurrentState == SERVICE_STOPPED )
_tprintf(TEXT("\n%s stopped.\n"), TEXT(SZSERVICEDISPLAYNAME) );
else
_tprintf(TEXT("\n%s failed to stop.\n"), TEXT(SZSERVICEDISPLAYNAME) );
}
// now remove the service
if( DeleteService(schService) )
_tprintf(TEXT("%s removed.\n"), TEXT(SZSERVICEDISPLAYNAME) );
else
_tprintf(TEXT("DeleteService failed - %s\n"), windows_error_string(szErr, (sizeof(szErr)/sizeof(TCHAR))));
CloseServiceHandle(schService);
}
else
_tprintf(TEXT("OpenService failed - %s\n"), windows_error_string(szErr, (sizeof(szErr)/sizeof(TCHAR))));
CloseServiceHandle(schSCManager);
}
else
_tprintf(TEXT("OpenSCManager failed - %s\n"), windows_error_string(szErr, (sizeof(szErr)/sizeof(TCHAR))));
}
#endif

View File

@ -51,11 +51,6 @@ VOID LogEventErrorMessage(LPTSTR lpszMsg);
VOID LogEventWarningMessage(LPTSTR lpszMsg);
VOID LogEventInfoMessage(LPTSTR lpszMsg);
// Service Maintenance Routines
VOID CmdInstallService();
VOID CmdUninstallService();
#ifdef __cplusplus
}
#endif

Binary file not shown.