From 8c57c534da75ca335cd90ca13944d47d5a0ba0e9 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 12 Nov 2004 18:11:31 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=4532 --- checkin_notes | 12 +- client/cs_cmdline.C | 6 +- client/main.C | 12 +- client/win/win_service.cpp | 206 +------------------------------- client/win/win_service.h | 5 - win_build/installerv2/BOINC.ism | Bin 203728 -> 203728 bytes 6 files changed, 23 insertions(+), 218 deletions(-) diff --git a/checkin_notes b/checkin_notes index 73f6c3fdf1..377ae57aa3 100755 --- a/checkin_notes +++ b/checkin_notes @@ -19288,4 +19288,14 @@ Rom 12 Nov 2004 BOINC.ism win_build/installerv2/redist/Windows/ BOINC.vbs - \ No newline at end of file + +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 diff --git a/client/cs_cmdline.C b/client/cs_cmdline.C index 847090fe54..8fd0b5990f 100644 --- a/client/cs_cmdline.C +++ b/client/cs_cmdline.C @@ -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" diff --git a/client/main.C b/client/main.C index 26e8c2565a..bc65960c88 100644 --- a/client/main.C +++ b/client/main.C @@ -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. diff --git a/client/win/win_service.cpp b/client/win/win_service.cpp index 08bb28e466..2529c25b1b 100644 --- a/client/win/win_service.cpp +++ b/client/win/win_service.cpp @@ -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 + diff --git a/client/win/win_service.h b/client/win/win_service.h index 218b1aa8e4..0410a824b9 100644 --- a/client/win/win_service.h +++ b/client/win/win_service.h @@ -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 diff --git a/win_build/installerv2/BOINC.ism b/win_build/installerv2/BOINC.ism index c731b5c4eed66b4fa8c05baa127b93ba67b81e79..d1fe329380fa1efb5d2daf8a020fdf194a6c1f01 100644 GIT binary patch delta 288 zcmcbxo#(=Ko((xHtP4Efy?L~`kcFL}QMtKNxV=)CaeJjO(|s`(t(!BRZjaGon#RNU zZu@65rsJDg!(E+}m8buI#-y-a_chaHo@pG+e%pR9&EsRb$Gd$28*>8Vc0Ug0O^lPZ zb9ko*NHKCu7v*ENT*k%BvfYo5xs-AGu2)PdZchH5e$EOd`3fod<#{>zi75)@`9;~K zd6^}}3W<3s3I#>^$*IM~3MCn-xeDc(B^mjpB?_g*sYMEzc_pbuiOD6I`FVQN5A!oC zE)!s8Q!Y*}3QA4SEG{XkGzv~GN=?lRPAp4x1S%^_4NpyC1iE^=vKVtJGcyAN!}e}T g=J$+@Ow+5SnQbMq7#JCNfLH>EIe}OJh}nS{0G@qZV*mgE delta 219 zcmcbxo#(=Ko((xHtOjyl{#@H!$imLg$lhEj++HcnxV=)C>Ao0CY2S>y+heqtrtvT) zZU1b>bbRylQhsI?&6ND|yqx^Rl+3(zh4TEO?9#l^D`?> z6JwTHCcw