Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inno Setup - not uniinstalling
Message
 
To
19/09/2006 12:32:02
General information
Forum:
Visual FoxPro
Category:
Installation, Setup and Configuration
Miscellaneous
Thread ID:
01155148
Message ID:
01155577
Views:
19
Frank,

Try

Uninstallable=yes

in the [Setup] section.

(for more options, search for Uninstall in the Inno Help.)

>Hi,
>
>I've got the following script to install a windows service. It works successfully. However, when I try to uninstall using Add/Remove Programs, nothing happens. I've looked in the registry at HKLM\Software\Microsoft\CurrentVersion\Uninstall\SSL1_isl which holds the uninstall info for my app (Appid was SSL1) and the "Inno Setup: App Path" was blank, the "QuietUninstallString" pointed to "c:\windows\unins001.exe" /SILENT and "UninstallString" to "c:\windows\unins001.exe".
>
>Can anyone tell me why this is happening?
>
>
>#define MyAppName "CB App Test"
>#define MyAppVerName "CB App Test"
>#define MyAppPublisher "SigmaSoft International Inc."
>#define MyAppURL "http://SigmaSoft.com"
>#define MyAppExeName "cb.exe"
>
>[Setup]
>AppName={#MyAppName}
>AppVerName={#MyAppVerName}
>AppId=SSL1
>AppPublisher={#MyAppPublisher}
>AppPublisherURL={#MyAppURL}
>AppSupportURL={#MyAppURL}
>AppUpdatesURL={#MyAppURL}
>DefaultDirName={pf}\{#MyAppName}
>AppVersion=1.0
>DefaultGroupName={#MyAppVerName}
>Compression=lzma
>SolidCompression=true
>OutputBaseFilename={#MyAppName} setup
>CreateAppDir=no
>DisableProgramGroupPage=yes
>
>[Messages]
>BeveledLabel=© 2006 Samaan Systems Ltd.
>
>[Files]
>;**********************************************************************
>;
>;	searchserver component files
>;
>;**********************************************************************
>Source: C:\Program Files\Netrics\netricsd-3.3.11-ET-eval.exe; DestDir: {code:GetSearchDir}; Flags: ignoreversion; BeforeInstall: DoPreInstall(); AfterInstall: DoServiceInstall('{code:GetSearchDir}\netricsd-3.3.11-ET-eval.exe')
>
>[Code]
>type
> SERVICE_STATUS = record
>     dwServiceType    : cardinal;
>     dwCurrentState    : cardinal;
>     dwControlsAccepted   : cardinal;
>     dwWin32ExitCode    : cardinal;
>     dwServiceSpecificExitCode : cardinal;
>     dwCheckPoint    : cardinal;
>     dwWaitHint     : cardinal;
> end;
> HANDLE = cardinal;
>
>const
> SERVICE_QUERY_CONFIG  = $1;
> SERVICE_CHANGE_CONFIG  = $2;
> SERVICE_QUERY_STATUS  = $4;
> SERVICE_START    = $10;
> SERVICE_STOP    = $20;
> SERVICE_ALL_ACCESS   = $f01ff;
> SC_MANAGER_ALL_ACCESS  = $f003f;
> SERVICE_WIN32_OWN_PROCESS = $10;
> SERVICE_WIN32_SHARE_PROCESS = $20;
> SERVICE_WIN32    = $30;
> SERVICE_INTERACTIVE_PROCESS = $100;
> SERVICE_BOOT_START          = $0;
> SERVICE_SYSTEM_START        = $1;
> SERVICE_AUTO_START          = $2;
> SERVICE_DEMAND_START        = $3;
> SERVICE_DISABLED            = $4;
> SERVICE_DELETE              = $10000;
> SERVICE_CONTROL_STOP  = $1;
> SERVICE_CONTROL_PAUSE  = $2;
> SERVICE_CONTROL_CONTINUE = $3;
> SERVICE_CONTROL_INTERROGATE = $4;
> SERVICE_STOPPED    = $1;
> SERVICE_START_PENDING       = $2;
> SERVICE_STOP_PENDING        = $3;
> SERVICE_RUNNING             = $4;
> SERVICE_CONTINUE_PENDING    = $5;
> SERVICE_PAUSE_PENDING       = $6;
> SERVICE_PAUSED              = $7;
>
> var
>   SearchDirPage: TInputDirWizardPage;
>
>procedure InitializeWizard;
>begin
>	{ Create the search directory page }
>	SearchDirPage := CreateInputDirPage( wpSelectComponents,
>		'Select Search Server Directory', 'Where should the Search Server files be installed?',
>		'Setup will install the Search Server files into the following folder.',
>		False, 'New Folder');
>	SearchDirPage.Add( 'To continue, click Next. If you would like to select a different location, click Browse');
>
>end;
>
>procedure RegisterPreviousData( PreviousDataKey: Integer);
>begin
>   { Save the DataDir setting so we can restore it next time }
>   SetPreviousData( PreviousDataKey, 'SearchDir', SearchDirPage.Values[0]);
>end;
>
>procedure CurPageChanged(curPageID: Integer);
>begin
>
>  if CurPageID = SearchDirPage.ID then
>    SearchDirPage.Values[0] := GetPreviousData('SearchDir', ExpandConstant('{pf}') + '\CB Test')
>
>end;
>
>function GetSearchDir( S: String): String;
>begin
>   { Return the selected DataDir }
>   Result := SearchDirPage.Values[0];
>end;
>
>//
>// nt based service utilities
>//
>function OpenSCManager(lpMachineName, lpDatabaseName: string;
>dwDesiredAccess :cardinal): HANDLE;
>external 'OpenSCManagerA@advapi32.dll stdcall';
>
>function OpenService(hSCManager :HANDLE;lpServiceName: string;
>dwDesiredAccess :cardinal): HANDLE;
>external 'OpenServiceA@advapi32.dll stdcall';
>
>function CloseServiceHandle(hSCObject :HANDLE): boolean;
>external 'CloseServiceHandle@advapi32.dll stdcall';
>
>function CreateService(hSCManager :HANDLE;lpServiceName, lpDisplayName:
>string;dwDesiredAccess,dwServiceType,dwStartType,dwErrorControl:
>cardinal;lpBinaryPathName,lpLoadOrderGroup: String; lpdwTagId :
>cardinal;lpDependencies,lpServiceStartName,lpPassword :string): cardinal;
>external 'CreateServiceA@advapi32.dll stdcall';
>
>function DeleteService(hService :HANDLE): boolean;
>external 'DeleteService@advapi32.dll stdcall';
>
>function StartNTService(hService :HANDLE;dwNumServiceArgs :cardinal;lpServiceArgVectors : cardinal) : boolean;
>external 'StartServiceA@advapi32.dll stdcall';
>
>function ControlService(hService :HANDLE; dwControl :cardinal;var ServiceStatus :SERVICE_STATUS) : boolean;
>external 'ControlService@advapi32.dll stdcall';
>
>function QueryServiceStatus(hService :HANDLE;var ServiceStatus :SERVICE_STATUS) : boolean;
>external 'QueryServiceStatus@advapi32.dll stdcall';
>
>function QueryServiceStatusEx(hService :HANDLE;ServiceStatus :SERVICE_STATUS) : boolean;
>external 'QueryServiceStatus@advapi32.dll stdcall';
>
>function GetPathInstalled( AppID: String ): String;
>var
>   sPrevPath: String;
>begin
>  sPrevPath := '';
>  if not RegQueryStringValue( HKLM, 'Software\Microsoft\Windows\CurrentVersion\Uninstall'+AppID+'_is1', 'Inno Setup: App Path', sPrevpath) then
>    RegQueryStringValue( HKCU, 'Software\Microsoft\Windows\CurrentVersion\Uninstall'+AppID+'_is1' , 'Inno Setup: App Path', sPrevpath);
>
>  Result := sPrevPath;
>end;
>
>
>function OpenServiceManager() : HANDLE;
>begin
> if UsingWinNT() then begin
>  Result := OpenSCManager('','ServicesActive',SC_MANAGER_ALL_ACCESS);
>  if Result = 0 then
>   MsgBox('the servicemanager is not available', mbError, MB_OK)
> end
> else begin
>   MsgBox('only nt based systems support services', mbError, MB_OK)
>   Result := 0;
> end
>end;
>
>function IsServiceInstalled(ServiceName: string) : boolean;
>var
> hSCM : HANDLE;
> hService: HANDLE;
>begin
> hSCM := OpenServiceManager();
> Result := false;
> if hSCM <> 0 then begin
>  hService := OpenService(hSCM,ServiceName,SERVICE_QUERY_CONFIG);
>        if hService <> 0 then begin
>            Result := true;
>            CloseServiceHandle(hService)
>  end;
>        CloseServiceHandle(hSCM)
> end
>end;
>
>function InstallService(FileName, ServiceName, DisplayName, Description :
>string;ServiceType,StartType :cardinal) : boolean;
>var
> hSCM : HANDLE;
> hService: HANDLE;
>begin
> hSCM := OpenServiceManager();
> Result := false;
> if hSCM <> 0 then begin
>  hService := CreateService(hSCM,ServiceName,DisplayName,SERVICE_ALL_ACCESS,ServiceType,StartType,0,FileName,'',0,'','','');
>  if hService <> 0 then begin
>   Result := true;
>   // Win2K & WinXP supports aditional description text for services
>   if Description<> '' then
>    RegWriteStringValue(HKLM,'System\CurrentControlSet\Services\' + ServiceName,'Description',Description);
>   CloseServiceHandle(hService)
>  end;
>        CloseServiceHandle(hSCM)
> end
>end;
>
>function RemoveService(ServiceName: string) : boolean;
>var
> hSCM : HANDLE;
> hService: HANDLE;
>begin
> hSCM := OpenServiceManager();
> Result := false;
> if hSCM <> 0 then begin
>  hService := OpenService(hSCM,ServiceName,SERVICE_DELETE);
>        if hService <> 0 then begin
>            Result := DeleteService(hService);
>            CloseServiceHandle(hService)
>  end;
>        CloseServiceHandle(hSCM)
> end
>end;
>
>function StartService(ServiceName: string) : boolean;
>var
> hSCM : HANDLE;
> hService: HANDLE;
>begin
> hSCM := OpenServiceManager();
> Result := false;
> if hSCM <> 0 then begin
>  hService := OpenService(hSCM,ServiceName,SERVICE_START);
>        if hService <> 0 then begin
>         Result := StartNTService(hService,0,0);
>            CloseServiceHandle(hService)
>  end;
>        CloseServiceHandle(hSCM)
> end;
>end;
>
>function StopService(ServiceName: string) : boolean;
>var
> hSCM : HANDLE;
> hService: HANDLE;
> Status : SERVICE_STATUS;
>begin
> hSCM := OpenServiceManager();
> Result := false;
> if hSCM <> 0 then begin
>  hService := OpenService(hSCM,ServiceName,SERVICE_STOP);
>        if hService <> 0 then begin
>         Result := ControlService(hService,SERVICE_CONTROL_STOP,Status);
>            CloseServiceHandle(hService)
>  end;
>        CloseServiceHandle(hSCM)
> end;
>end;
>
>function IsServiceRunning(ServiceName: string) : boolean;
>var
> hSCM : HANDLE;
> hService: HANDLE;
> Status : SERVICE_STATUS;
>begin
> hSCM := OpenServiceManager();
> Result := false;
> if hSCM <> 0 then begin
>  hService := OpenService(hSCM,ServiceName,SERVICE_QUERY_STATUS);
>     if hService <> 0 then begin
>   if QueryServiceStatus(hService,Status) then begin
>    Result :=(Status.dwCurrentState = SERVICE_RUNNING)
>         end;
>            CloseServiceHandle(hService)
>      end;
>        CloseServiceHandle(hSCM)
> end
>end;
>
>procedure DoPreInstall();
>var i:integer;
>begin
> if IsServiceInstalled('Netrics Search Server') then begin
>   If StopService('Netrics Search Server') then
>   begin
>     i := 0;
>        while isServiceRunning('Netrics Search Server') and (i<10) do
>       begin
>      sleep(2000);
>      i := i + 1;
>      end;
>      If (i>=10) then
>        msgbox('Could not stop Netrics Search Server',mbError, MB_OK);
>      end else msgbox('Could not stop Netrics Search Server',mbError, MB_OK);
> end;
>end;
>
>Procedure DoserviceInstall( fname: string);
>var filename:string;
>begin
> if not IsServiceInstalled('Netrics Search Server') then begin
>   filename := expandConstant(fname);
>   msgbox('Service does not exist',mbInformation,MB_OK);
>  if InstallService(filename,'Netrics Search Server','Netrics Search Server','Netrics Search Server',SERVICE_WIN32_OWN_PROCESS,SERVICE_AUTO_START) = true then begin
>   if StartService('Netrics Search Server') then
>     msgbox('Service installed successfully',mbInformation,MB_OK)
>    else
>      msgbox('Service installed but could not be started',mbInformation,MB_OK);
>  end else
>     msgbox('Attempt to install Netrics Search Server failed',mbError,MB_OK);
> end else
> begin
>   msgbox('Service does exist',mbInformation,MB_OK);
>    if StartService('Netrics Search Server') then
>     msgbox('Service installed successfully',mbInformation,MB_OK)
>   else
>       msgbox('Service installed but could not be started',mbInformation,MB_OK);
> end;
>end;
>
>
>//
>// version functions
>//
>function CheckVersion(Filename : string;hh,hl,lh,ll : integer) : boolean;
>var
> VersionMS : cardinal;
> VersionLS : cardinal;
> CheckMS  : cardinal;
> CheckLS  : cardinal;
>begin
> if not GetVersionNumbers(Filename,VersionMS,VersionLS)then
>  Result := false
> else begin
>  CheckMS := (hh shl $10) or hl;
>  CheckLS := (lh shl $10) or ll;
>  Result := (VersionMS > CheckMS) or ((VersionMS = CheckMS) and (VersionLS >= CheckLS));
> end;
>end;
>
>function InitializeUninstall(): Boolean;
>var i:integer;
>begin
> if IsServiceInstalled('Netrics Search Server') then begin
>   If StopService('Netrics Search Server') then
>   begin
>     i := 0;
>        while isServiceRunning('Netrics Search Server') and (i<10) do
>       begin
>      sleep(2000);
>      i := i + 1;
>      end;
>      If (i>=10) then
>        msgbox('Could not stop Netrics Search Server',mbError, MB_OK) else
>      begin
>        If RemoveService('Netrics Search Server') then begin
>//           msgbox('Netrics Search Server service successfully uninstalled',mbInformation, MB_OK)
>         end else
>           msgbox('Failed to remove Netrics Search Server service',mberror, MB_OK);
>       end;
>      end else msgbox('Could not stop Netrics Search Server service',mbError, MB_OK);
> end;
>end;
>
Mike C.
-------
I keep trying to find a life of my own, apart from you.
DC Talk/Charlie Peacock, In the Light.
www.risensystems.com/ra/itlbegin.rm
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform