Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   como ejecutar el UninstallString en codigo de innosetup (https://www.clubdelphi.com/foros/showthread.php?t=82512)

teecweb 14-03-2013 00:51:30

como ejecutar el UninstallString en codigo de innosetup
 
Holas
tengo dos Uninstallstring de diferentes software instalados
MsiExec.exe /I{B87A2859-3187-4D05-B0D3-A21491128D26}
C:\Archivos de programa\abc\unnistall.exe
lo eh tratado de ejecutar con Exec:

donde el filename es el Uninstallstring ..ninguna de las rutas lo reconoce..bueno en si lo que kiero hacer
es como ejecutar el Uninstallstring desde codigo de innosetup
porque exec no me funciona..gracias por sus respuestas..:D
Código Delphi [-]
 Param :=  ' /VERYSILENT /SUPPRESSMSGBOXES';
if not Exec(FileName,Param, '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
           begin
            MsgBox('DeinitializeSetup:' #13#13 'Execution of ''' + FileName + ''' failed. ' + 

SysErrorMessage(ErrorCode) + '.', mbError, MB_OK);
            end
       else
       begin
        CheckListBox1.ItemEnabled[i]:= False;
            //MsgBox('correcto',mbInformation, MB_OK);
       end;

maeyanes 14-03-2013 16:21:35

Hola...

¿Y por que no te funciona? ¿Qué mensaje de error obtienes?

Checa este link: InnoSetup: How to automatically uninstall previous installed version?, a lo mejor te sirve...


Saludos...

teecweb 14-03-2013 17:45:39

Holas ..:D

este error me sale para en los dos UnnistallString
Código Delphi [-]
Execution of 'MsiExec.exe /I{B87A2859-3187-4D05-B0D3-A21128D26}' failed.El sistema no puede hallar el
archivo especificado


Execution of '''C:\Archivos de programa \Sistema Abc version 1.2\Desinstalar\unins000.exe''' failed.El sistema no puede hallar el
archivo especificado

teecweb 14-03-2013 17:56:06

leere el post ..gracias

teecweb 14-03-2013 18:10:13

Holas eh agregado el removeQuotes segun el post que me mando funciono para el segundo UninstallString pero para el primero salio ese error:
Código Delphi [-]

Execution of 'MsiExec.exe /I{B87A2859-3187-4D05-B0D3-A21128D26}' failed.El sistema no puede hallar el
archivo especificado

Código Delphi [-]
 procedure desinstalarTotal(const FileName: string;var i: integer);
 var 
 ErrorCode : integer;
 Param : String;
    begin
     Param :=  ' /VERYSILENT /SUPPRESSMSGBOXES';
    FileName := RemoveQuotes(FileName);
    MsgBox('sin comillas '#13#10#13#10 + FileName, mbInformation, MB_OK);
      if not Exec(FileName,Param, '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
           begin
            MsgBox('DeinitializeSetup:' #13#13 'Execution of ''' + FileName + ''' failed. ' + 

SysErrorMessage(ErrorCode) + '.', mbError, MB_OK);
            end
       else
       begin
        CheckListBox1.ItemEnabled[i]:= False;
            //MsgBox('correcto',mbInformation, MB_OK);
       end;     
    end;

maeyanes 14-03-2013 18:20:10

Hola...

Por lo que veo, en el primer caso solo tienes el nombre del archivo ejecutable y no la ruta completa, lo que hace que InnoSetup trate de ejecutar el archivo desde la carpeta actual, el cual al no existir en esta es que te produce el error. Ahí el problema ya viene siendo del instalador de la aplicación original que no creó bien la cadena de desinstalación.



Saludos...

teecweb 14-03-2013 18:37:26

Holas
eh revisado el regedit y tambien existen varias UninstallString de esa forma

como por ejemplo:
el de : Microsoft Silverlight
UninstallString : MsiExec.exe/X{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}

maeyanes 14-03-2013 18:44:23

Hola...

Entonces el problema está en que a la función exec le estás enviando un nombre de archivo que nunca va a encontrar, ya que en este viene incluido un parámetro. Lo que tienes que hacer es separar el nombre del archivo del parámetro. Esto es:

Código Delphi [-]
var
  ExeFileName: string;
  ParamStr: string;
  SlashPos: Integer;

begin
  SlashPos := Pos(FileName, '/');
  if SlashPos > 0 then
  begin
    ExeFileName := Copy(FileName, 0, SlashPos - 1);
    ParamStr := Copy(FileName, SlashPos, Length(FileName))
  end
end;

También recuerda que no todos los instaladores son hechos con InnoSetup y no van a soportar los mismos parámetros.


Saludos...

teecweb 14-03-2013 21:40:53

Probare el codigo, gracias :D

teecweb 14-03-2013 22:20:54

en realidad no entiendo que hace rl codigo y como funcionaria en exec para la desisntalacion?

maeyanes 14-03-2013 22:26:48

Hola...

Lo único que hace ese código es separar el nombre del ejecutable del parámetro, esto es, en cada variable queda una parte del string original.

Código Delphi [-]
FileName := 'MsiExec.exe /I{B87A2859-3187-4D05-B0D3-A21128D26}';

// Se ejecuta el código que te puse y devuelve:
ExeFileName := 'MsiExec.exe';
ParamStr := '/I{B87A2859-3187-4D05-B0D3-A21128D26}';

// Usas las dos variables en la función exec:
if not Exec(ExecFileName, ParamStr, '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
  // ...


Saludos...

teecweb 15-03-2013 00:37:54

Holas .. si salio pero en caso de esos UninstallString : MsiExec.exe/X{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}..como son instaladores hechos en windows installer sale la pantalla de desinstalacion pero quisera que fuera en modo silencioso ya que en inno setup tiene sus propios comandos
lo eh estado haciendo asi pero no me borra el archivo..aqui le paso el codigo aunque falta mejorar..
Código Delphi [-]

 procedure desinstalarTotal(const FileName: string;var i: integer);
 var 
 ErrorCode : integer;
 Param : String;
 
 ExecFileName: string;
 ParamStr: string;
 SlashPos: Integer;
    begin
     Param :=  ' /VERYSILENT /SUPPRESSMSGBOXES';
    FileName := RemoveQuotes(FileName);
    
    SlashPos := Pos('/' ,FileName );
    if SlashPos > 0 then
    begin
        ExecFileName := Copy(FileName, 0, SlashPos - 1);
        ParamStr := Copy(FileName, SlashPos, Length(FileName))

    
       if not Exec(ExecFileName, ParamStr + ' /quiet', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
           begin
            MsgBox('DeinitializeSetup:' #13#13 'Execution of ''' + FileName + ''' failed. ' + 

                SysErrorMessage(ErrorCode) + '.', mbError, MB_OK);
            end
       else
       begin
        CheckListBox1.ItemEnabled[i]:= False;
       end;     
    end
    else
    begin
       if not Exec(FileName,Param, '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
           begin
            MsgBox('DeinitializeSetup:' #13#13 'Execution of ''' + FileName + ''' failed. ' + 

                SysErrorMessage(ErrorCode) + '.', mbError, MB_OK);
            end
       else
       begin
        CheckListBox1.ItemEnabled[i]:= False;
       end; 
    
    end;
    end;

teecweb 15-03-2013 02:30:55

Holas..ya me salio ..igualemnte gracias..aqui le dejo el codigo
Código Delphi [-]
 procedure desinstalarTotal(const FileName: string;var i: integer;var name: String);
 var 
 ErrorCode : integer;
 Param : String;
 
 ExecFileName: string;
 ParamStr: string;
 SlashPos: Integer;
    begin
     Param :=  ' /VERYSILENT /SUPPRESSMSGBOXES';
    FileName := RemoveQuotes(FileName);
    
    SlashPos := Pos('/' ,FileName );
    if SlashPos > 0 then
    begin
        ExecFileName := Copy(FileName, 0, SlashPos - 1);
        ParamStr := Copy(FileName, SlashPos, Length(FileName))

    
      // if not Exec(ExecFileName, '/x {B87A2859-3187-4D05-B0D3-A21491128D26} /quiet', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
        if not Exec(ExecFileName, '/x '+name+' /quiet', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then 
           begin
            MsgBox('DeinitializeSetup:' #13#13 'Execution of ''' + FileName + ''' failed. ' + 

                SysErrorMessage(ErrorCode) + '.', mbError, MB_OK);
                 CheckListBox1.ItemEnabled[i]:= True;
            end
       else
       begin
        CheckListBox1.ItemEnabled[i]:= False;
       end;     
    end
    else
    begin
       if not Exec(FileName,Param, '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
           begin
            MsgBox('DeinitializeSetup:' #13#13 'Execution of ''' + FileName + ''' failed. ' + 

                SysErrorMessage(ErrorCode) + '.', mbError, MB_OK);
            end
       else
       begin
        CheckListBox1.ItemEnabled[i]:= False;
       end; 
    
    end;
    end;


La franja horaria es GMT +2. Ahora son las 09:10:33.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi