kumarkiranc
Posts: 85
Joined: Tue Sep 18, 2007 6:49 am

Uninstall Using VBScript

hi,

Iam trying to uninstall the SQL Express through VBSCript.
I add the vbs file in custom action in INstallFinallize.
Execution condition > remove=all

when i uninstall it gives me a error another apllication is running. How can i do it in Advance Installer using VBScript.

Eg VBScript file.
on error resume next
Set WshShell = CreateObject("WScript.Shell")

' Uninstall OWC11
WshShell.Run "msiexec /x {90A40409-6000-11D3-8CFE-0150048383C9} /qb",1,True


Thanks
Kiran
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

In order to uninstall SQL Express, you first need to stop the service it uses. For this, you can use this custom action:

Code: Select all

Option Explicit
Dim objWMIService, objItem, objService
Dim colListOfServices, strComputer, strService
strComputer = "."

strService = " 'MSSQLSERVER' "
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name ="_
& strService & " ")

For Each objService in colListOfServices
objService.StopService()
Next
Since the SQL Server uses other services besides the main one, you need to close them as well. This can also be done with a custom action (simply set the ID of another service instead of MSSQLSERVER).

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kumarkiranc
Posts: 85
Joined: Tue Sep 18, 2007 6:49 am

Hi,

when i uninstall it gives me a error
"Another installation is already in Progress. Complete that installtion before proceeding with this install"

iam running VBscript at InstallFinallize > Execution condition > remove=all

Eg VBScript file.
on error resume next
Set WshShell = CreateObject("WScript.Shell")

' Uninstall OWC11
WshShell.Run "msiexec /x {90A40409-6000-11D3-8CFE-0150048383C9} /qb",1,True



Thanks
Kiran
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

This happens because the custom action is scheduled under "InstallFinalize" when the install (or uninstall) process is still running.

In order to avoid this behavior you need to add the custom action under the "UI Custom Actions" tree in the "Custom Actions" page. After this, you go to the "Dialogs" page and add the custom action as a DoAction Published control event for the "Finish" button on "ExitDialog".

This way, the custom action will be executed after the install (or uninstall) process has finished.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”