Problem with VBScript SUB for uninstalling .MSI packages 
Author Message
 Problem with VBScript SUB for uninstalling .MSI packages

Hey guys,

the following script is supposed to catch an error from Windows
Installer. I've made an installation routine that does it. However,
the
installation routine uses the Installer object. As the
Installer-object
has no uninstall method, I have to call msiexec /x <product> /qb.

According to the Windows Installer SDK error codes table, my script
should work. However, it doesn't. It seems every error code, no matter
if I press cancel or whatever I do, is 0 !

Can someone tell me why the error-code is always 0 ? When using the
installer object it's easy. But this is obviously different.

I can make it catch that there is "an" error. But I can't seem to echo
which one.

I hope someone can help me out ! And, I'm sorry for posting to three
newsgroups at the same time, but I'm not quite sure which one would be
the correct one to write to. Hope you can bear with me ;o)

The code itself is:

' Author: Jacob Saaby Nielsen

' Date: 16-07-2001
' Description: Wrapper to counter-effect users pushing cancel-button

OPTION EXPLICIT

'--- Initialiser og erkl?r objekter

DIM WshShell : SET WshShell=WScript.CreateObject("WScript.Shell")
DIM FSO : SET FSO=CreateObject("Scripting.FileSystemObject")
DIM MWI : SET MWI=CreateObject("WindowsInstaller.Installer")

DIM strCurPath : strCurPath = FSO.GetAbsolutePathName(".")
DIM ESkat96GUID : ESkat96GUID =
"{84DFF8D1-69AC-445E-AD99-AB3AF3C841BA}"
DIM ProdCode

UnInstPkg (ESkat96GUID)

SUB UnInstPkg (ProdCode)

  DIM MsiExec : MsiExec = WshShell.ExpandEnvironmentStrings("%
systemroot%") & "\system32\msiexec.exe "
  DIM SilentBasic : SilentBasic = " /qb"
  DIM UnInst : UnInst = " /x "
  DIM UnInstTxt : UnInstTxt = "Afinstallationen er blevet afbrudt !" &
vbCrLf & "Af-installationen genstartes 10 sekunder fra nu, eller n?r"
&
vbCrLf & "du trykker p? OK knappen."
  DIM UnInstCancelTxt : UnInstCancelTxt = "Du har trykket p? Cancel
knappen !" & vbCrLf & "Af-installationen genstartes 10 sekunder fra
nu,
eller n?r" & vbCrLf & "du trykker p? OK knappen."
  DIM UnInstRunningTxt : UnInstRunningTxt = "En anden
installation/afinstallation k?rer allerede !" & vbCrLf & "Af-
installationen genstartes 10 sekunder fra nu, eller n?r" & vbCrLf &
"du
trykker p? OK knappen."
  DIM UnInstTitle : UnInstTitle = "Uninstallation Wrapper v1.0"
  DIM UnInstResult : UnInstResult = 1

  IF MWI.ProductState (ProdCode) = 5 THEN

        DO WHILE UnInstResult <> 0
          WshShell.Run MsiExec & UnInst & ProdCode & SilentBasic, 0, TRUE
      UnInstResult = Err.Number

      SELECT CASE UnInstResult
        CASE "1602"           WshShell.Popup UnInstCancelTxt, 10,
UnInstTitle, vbCritical
        CASE "1618"           WshShell.Popup UnInstRunningTxt, 10,
UnInstTitle, vbCritical
      CASE ELSE
            WshShell.Popup UnInstTxt, 10, UnInstTitle, vbCritical
                UnInstResult = Err.Number
                Err.Clear
      END SELECT
        LOOP
      UnInstResult = 1
  END IF

END SUB

'--- Exit'er scriptet

WScript.Quit

--
Jacob S. Nielsen
http://www.*-*-*.com/
(It'd be real nice of you, if you could CC the answer to my e-mail:



Mon, 05 Jan 2004 17:41:37 GMT  
 Problem with VBScript SUB for uninstalling .MSI packages

UnInstResult =  WshShell.Run(MsiExec & UnInst & ProdCode & SilentBasic, 0, TRUE)

The Run method does **not** raise a COM error if the program executed returns a non-zero exit code,
but does return it as the Run method's return value when you wait for completion...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--



Quote:
> Hey guys,

> the following script is supposed to catch an error from Windows
> Installer. I've made an installation routine that does it. However,
> the
> installation routine uses the Installer object. As the
> Installer-object
> has no uninstall method, I have to call msiexec /x <product> /qb.

> According to the Windows Installer SDK error codes table, my script
> should work. However, it doesn't. It seems every error code, no matter
> if I press cancel or whatever I do, is 0 !

> Can someone tell me why the error-code is always 0 ? When using the
> installer object it's easy. But this is obviously different.

> I can make it catch that there is "an" error. But I can't seem to echo
> which one.

> I hope someone can help me out ! And, I'm sorry for posting to three
> newsgroups at the same time, but I'm not quite sure which one would be
> the correct one to write to. Hope you can bear with me ;o)

> The code itself is:

> ' Author: Jacob Saaby Nielsen

> ' Date: 16-07-2001
> ' Description: Wrapper to counter-effect users pushing cancel-button

> OPTION EXPLICIT

> '--- Initialiser og erkl?r objekter

> DIM WshShell : SET WshShell=WScript.CreateObject("WScript.Shell")
> DIM FSO : SET FSO=CreateObject("Scripting.FileSystemObject")
> DIM MWI : SET MWI=CreateObject("WindowsInstaller.Installer")

> DIM strCurPath : strCurPath = FSO.GetAbsolutePathName(".")
> DIM ESkat96GUID : ESkat96GUID =
> "{84DFF8D1-69AC-445E-AD99-AB3AF3C841BA}"
> DIM ProdCode

> UnInstPkg (ESkat96GUID)

> SUB UnInstPkg (ProdCode)

>   DIM MsiExec : MsiExec = WshShell.ExpandEnvironmentStrings("%
> systemroot%") & "\system32\msiexec.exe "
>   DIM SilentBasic : SilentBasic = " /qb"
>   DIM UnInst : UnInst = " /x "
>   DIM UnInstTxt : UnInstTxt = "Afinstallationen er blevet afbrudt !" &
> vbCrLf & "Af-installationen genstartes 10 sekunder fra nu, eller n?r"
> &
> vbCrLf & "du trykker p? OK knappen."
>   DIM UnInstCancelTxt : UnInstCancelTxt = "Du har trykket p? Cancel
> knappen !" & vbCrLf & "Af-installationen genstartes 10 sekunder fra
> nu,
> eller n?r" & vbCrLf & "du trykker p? OK knappen."
>   DIM UnInstRunningTxt : UnInstRunningTxt = "En anden
> installation/afinstallation k?rer allerede !" & vbCrLf & "Af-
> installationen genstartes 10 sekunder fra nu, eller n?r" & vbCrLf &
> "du
> trykker p? OK knappen."
>   DIM UnInstTitle : UnInstTitle = "Uninstallation Wrapper v1.0"
>   DIM UnInstResult : UnInstResult = 1

>   IF MWI.ProductState (ProdCode) = 5 THEN

> DO WHILE UnInstResult <> 0
>   WshShell.Run MsiExec & UnInst & ProdCode & SilentBasic, 0, TRUE
>       UnInstResult = Err.Number

>       SELECT CASE UnInstResult
>         CASE "1602" WshShell.Popup UnInstCancelTxt, 10,
> UnInstTitle, vbCritical
>         CASE "1618" WshShell.Popup UnInstRunningTxt, 10,
> UnInstTitle, vbCritical
>       CASE ELSE
>     WshShell.Popup UnInstTxt, 10, UnInstTitle, vbCritical
> UnInstResult = Err.Number
> Err.Clear
>       END SELECT
> LOOP
>       UnInstResult = 1
>   END IF

> END SUB

> '--- Exit'er scriptet

> WScript.Quit

> --
> Jacob S. Nielsen
> http://www.modular-juice.net
> (It'd be real nice of you, if you could CC the answer to my e-mail:




Wed, 07 Jan 2004 09:10:38 GMT  
 Problem with VBScript SUB for uninstalling .MSI packages

Quote:

> UnInstResult =  WshShell.Run(MsiExec & UnInst & ProdCode & SilentBasic, 0, TRUE)

> The Run method does **not** raise a COM error if the program executed returns a non-zero exit code,
> but does return it as the Run method's return value when you wait for completion...

Hey Michael,

thanks for the help ! However, I've tried the above, and the exit-code
is still 0 no matter what.

Do you have any other ideas ? Is it somehow possible that I've
overlooked a method that can uninstall products, in the Installer
object ?

Or do I need to do something extra in addition to the above ?

Jacob Saaby Nielsen



Fri, 09 Jan 2004 18:35:20 GMT  
 Problem with VBScript SUB for uninstalling .MSI packages
Check out the ConfigureProduct method of the installer object.




Quote:

> > UnInstResult =  WshShell.Run(MsiExec & UnInst & ProdCode & SilentBasic,
0, TRUE)

> > The Run method does **not** raise a COM error if the program executed

returns a non-zero exit code,
Quote:
> > but does return it as the Run method's return value when you wait for
completion...

> Hey Michael,

> thanks for the help ! However, I've tried the above, and the exit-code
> is still 0 no matter what.

> Do you have any other ideas ? Is it somehow possible that I've
> overlooked a method that can uninstall products, in the Installer
> object ?

> Or do I need to do something extra in addition to the above ?

> Jacob Saaby Nielsen




Sat, 17 Jan 2004 10:29:15 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Problem with VBScript SUB for uninstalling .MSI packages

2. HOWTO: Check return values, boot status and (de)install status of MSI installations (Was: Problem with VBScript SUB for uninstalling .MSI packages)

3. HOWTO: Check return values, boot status and (de)install status of MSI installations (Was: Problem with VBScript SUB for uninstalling .MSI packages)

4. JScript from an msi, Windows Installer package

5. creating msi package

6. Installing MSI packages

7. Problems with SUB... END SUB

8. scripten.msi MSI Installer would be very nice

9. menus and sub-menus and sub-sub-menus

10. VBScript and msi.dll

11. VBScript Code Repositories for MSI custom actions?

12. impersonate MSI vbscript

 

 
Powered by phpBB® Forum Software