Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Test / troubleshoot a CA on uninstall
 

Test / troubleshoot a CA on uninstall

I have written a VBS that uninstall a driver. The VBS work when run from explorer or the command line but not as part as the uninstaller. I added the vbs to the Uninstall using the CA editor. I opened Orca and found the file in the file table. Went to the CustomAction table and found the action, type and source but no target. When adding the VBS to the CA uninstal I did not add a Condition or a customActionData. Is this a problem or ?
BarberColman  Wednesday, September 23, 2009 3:22 PM
You've got that reference to WScript that won't work. You don't need WScript.CreateObject anyway - just use CreateObject.

You also do what every darn VBScript I ever see does. You've got on error resume next, so it just goes blundering on through no matter what happens! I recommend taking that out and checking for errors with the err object, and using option explicit to make sure that you don't mis-spell any variables.

Then, if you uninstall and take a log:

msiexec /x {productcode guid} /l*v <path to a log file>

and there's a script syntax or runtime error it will show in the log.


Phil Wilson
  • Marked As Answer byBarberColman Thursday, September 24, 2009 4:49 PM
  •  
PhilWilson  Thursday, September 24, 2009 12:21 AM
There are too many possible reasons why a script custom action could fail. That is why they are not recommended by "the experts". Here are some references that may help you narrow down the issue with your script:

http://blogs.msdn.com/robmen/archive/2004/05/20/136530.aspx
http://blogs.msdn.com/heaths/archive/2007/05/31/windows-installer-errors-2738-and-2739-with-script-custom-actions.aspx
ColbyRingeisen  Wednesday, September 23, 2009 4:42 PM

My background is in the embedded with some C++. I modified a vbs script to search for and run a uninstall string. If you couold point me to a sample project that I could modifey?



strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys


For Each subkey In arrSubKeys
InstalledAppName = ""
InstalledAppName = WshShell.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\DisplayName")

'Wscript.Echo InstalledAppName'

If InStr(InstalledAppName, AppName) > 0 then
RawGUID = ""
RawGUID = WshShell.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\UninstallString")

If RawGUID<>"" then

WshShell.Run RawGUID

Exit For
End If
End If
Next

BarberColman  Wednesday, September 23, 2009 6:35 PM
VBScript hosted in Windows Installer is not the same as VBScript hosted in WSH. This doesn't look like the entire script anyway.

1) There is no WshShell object built in. So you can't use WshShell.RegRead. Where did WshShell come from anyway? I see no CreateObject for it.

2) There is also no WScript object, as you seem to have noticed by commenting it out.
Phil Wilson
PhilWilson  Wednesday, September 23, 2009 7:11 PM

I was only trying to show the logic not the complete script. Here is the complete script. I have a CA that runs the driver install during instal so I know the script engine is working. The install scrip is after theuninstall.
Thanks

Uinstall drivers VBS

On Error Resume Next
const AppName = "USB X(Driver Removal)"

const HKEY_LOCAL_MACHINE = &H80000002

Set WshShell = WScript.CreateObject("WScript.Shell")

strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys


For Each subkey In arrSubKeys
InstalledAppName = ""
InstalledAppName = WshShell.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\DisplayName")

'Wscript.Echo InstalledAppName'

If InStr(InstalledAppName, AppName) > 0 then
RawGUID = ""
RawGUID = WshShell.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\UninstallString")

If RawGUID<>"" then

WshShell.Run RawGUID

Exit For
End If
End If
Next


Install drivers VBS
Set WshShell = CreateObject("WScript.Shell")

WshShell.Run """" & Property("CustomActionData") & """",7,False

Set WshShell = Nothing

BarberColman  Wednesday, September 23, 2009 7:43 PM
You've got that reference to WScript that won't work. You don't need WScript.CreateObject anyway - just use CreateObject.

You also do what every darn VBScript I ever see does. You've got on error resume next, so it just goes blundering on through no matter what happens! I recommend taking that out and checking for errors with the err object, and using option explicit to make sure that you don't mis-spell any variables.

Then, if you uninstall and take a log:

msiexec /x {productcode guid} /l*v <path to a log file>

and there's a script syntax or runtime error it will show in the log.


Phil Wilson
  • Marked As Answer byBarberColman Thursday, September 24, 2009 4:49 PM
  •  
PhilWilson  Thursday, September 24, 2009 12:21 AM

Thanks for the suggestions. I am just an embedded programer who got ropped into supporting the install. Any sampl scripts that use the err object and option explicit?

BarberColman  Thursday, September 24, 2009 1:15 PM

You can use google to search for other answers

Custom Search

More Threads

• Setup project options help
• Get checkbox value on Deployment
• Error on install with excel version...global assembly cache issue on users computer
• Thirdy Party DLLS - Deploy using clickonce
• Install multiple instances of an msi on one box?
• BeforeUninstall
• Automating a click once deployment
• Uninstalling Msi projects programmatically
• Click once applications sharing dlls
• VS2005 Deployment installs files in drive root and not programfiles