splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Windows 7 64bit Registry Read Crash

Hi,

I have a strange one going on.

On one machine, Windows 7, 64bit, UAC turned off, Run as Administrator, as soon as I try read the registry from vbs it crashes.

This only happens on one machine (the bosses of course), we have other machines, same spec and it runs fine.

Here is a snippet from the MSI logs...
MSI (c) (F8:58) [17:38:51:404]: User policy value 'AlwaysInstallElevated' is 0
MSI (c) (F8:58) [17:38:51:404]: Product installation will be elevated because user is admin and product is being installed per-machine.
MSI (c) (F8:58) [17:38:51:404]: Running product '{D85B1EE6-0A1E-4A76-B67D-59090EE270F9}' with elevated privileges: Product is assigned.
The Error
MSI (c) (F8:40) [17:38:56:341]: Doing action: get_install_names_from_registry.vbs
Action 17:38:56: get_install_names_from_registry.vbs.
Action start 17:38:56: get_install_names_from_registry.vbs.
MSI (c) (F8:40) [17:38:56:341]: Note: 1: 2235 2: 3: ExtendedType 4: SELECT `Action`,`Type`,`Source`,`Target`, NULL, `ExtendedType` FROM `CustomAction` WHERE `Action` = 'get_install_names_from_registry.vbs'
Action ended 17:38:56: get_install_names_from_registry.vbs. Return value 3.
DEBUG: Error 2896: Executing action get_install_names_from_registry.vbs failed.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2896. The arguments are: get_install_names_from_registry.vbs, ,
Action ended 17:38:56: WelcomeDlg. Return value 3.
MSI (c) (F8:58) [17:38:56:377]: Doing action: FatalError
Action 17:38:56: FatalError.
Action start 17:38:56: FatalError.
MSI (c) (F8:58) [17:38:56:377]: Note: 1: 2235 2: 3: ExtendedType 4: SELECT `Action`,`Type`,`Source`,`Target`, NULL, `ExtendedType` FROM `CustomAction` WHERE `Action` = 'FatalError'
DEBUG: Error 2826: Control BottomLine on dialog FatalError extends beyond the boundaries of the dialog to the right by 3 pixels
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2826. The arguments are: FatalError, BottomLine, to the right
Action 17:38:56: FatalError. Dialog created
Action ended 17:38:59: FatalError. Return value 2.
Action ended 17:38:59: INSTALL. Return value 3.
MSI (c) (F8:58) [17:38:59:801]: Destroying RemoteAPI object.
MSI (c) (F8:A8) [17:38:59:801]: Custom Action Manager thread ending.
The vbs file...

Code: Select all



Dim debug
debug = false

Dim is_CTI_Install ' Dont show errors for local CRM install as they may be installing the client on the machine

is_CTI_Install = false

If Not debug then
	Dim db
	Set db = Session.Database
End If

If Debug then
	get_names
End IF


Function get_names()

	If Not debug then
		If Session.Property("AI_BUILD_NAME") = "CTI" Then
			is_CTI_Install = True
		End IF
	End If
	
	
	get_names = 1
	
	Const HKEY_LOCAL_MACHINE = &H80000002

	strComputer = "."
	 
	Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
	 
	If Not is_64_bit Then
		strKeyPath = "Software\eWare\Mappings"
	Else
		strKeyPath = "Software\Wow6432Node\eWare\Mappings"
	End IF
	
	on error resume next	
	oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes
	Dim reg_error
	reg_error = "The installer cannot find a version of Sage CRM on this machine." &_
				vbCrLf & "Please ensure you have a licensed version of CRM installed on this machine before proceeding."
	
	If Err.Number > 0 Then
		If NOT is_CTI_Install Then
			Session.Property( "CRM_INSTALL_CHECK" ) = "0"
			MsgBox  reg_error, 65, "Error"	
			get_names = -1
		End If
	Else
		Session.Property( "CRM_INSTALL_CHECK" ) = "1"
	End If
	
	
	If UBound(arrValueNames) < 0 Then
		If NOT is_CTI_Install Then
			Session.Property( "CRM_INSTALL_CHECK" ) = "0"
			get_names = -1
			MsgBox  reg_error, 65, "Error"
		End IF
		If Debug Then
			WScript.Echo "UBound(arrValueNames) < 0"
		End If
	Else
		Session.Property( "CRM_INSTALL_CHECK" ) = "1"
	End If
	
	index = 1

	
	For i=0 To UBound(arrValueNames)

	    	'Wscript.Echo "File Name: " & arrValueNames(i) & " -- "  
		
	   	'Wscript.Echo "Location: " & strValue
	    	'Wscript.Echo

		    install_name = arrValueNames(i) 
	    	oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath, arrValueNames(i), path
	    
		
		
			' stick them into the combo
			
			If Instr( install_name, "/" ) > 0 then
				
				    install_name = Replace( install_name, "/", "") 
			        SQLCmd = "INSERT INTO `ComboBox` (`Property`,`Order`,`Value`,`Text`)"
			    	SQLCmd = SQLCmd & " VALUES ('CRM_NAME','" &  index & "','" & install_name & "','"
			    	SQLCmd = SQLCmd & install_name & "') TEMPORARY"     
			    	Set view = db.OpenView( SQLCmd )
			    	view.Execute
			   	view.Close
				
				If debug Then
					Wscript.Echo install_name
				End If
				
				index = index + 1

			End IF
		
	
	Next
	
	
End  Function

Function is_64_bit()

	 const HKEY_LOCAL_MACHINE = &H80000002
	 strComputer = "."

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

	 strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
	 strValueName = "PROCESSOR_ARCHITECTURE"
	 oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
	 'WScript.Echo "Current Processor Archiecture: " & strValue
	  
	  Dim pos
		 pos = InStr( strValue, "64" ) 
		 If pos = 0 Then
			is_64_bit = False
		 Else
			is_64_bit = True
		 End If
 
End Function

On the machine in question if I run the vbs separately, it runs fine and has no troubles. It reads the registry and returns a value.

The problem of course is, during the install it crashes. It is like as if there is a permission issue, however, as you can see it is running as an admin.

Really appreciate any help.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Windows 7 64bit Registry Read Crash

Hello,

From what I understand, the vbscript works as an installer custom action on other machines, except your boss's.
That is indeed weird, it should't work on any. You are using the Wscript object inside your script, however that object is not available for custom action vbscripts.
However the explanation might be that your Wscript is used inside an IF statement which might only be executed on your boss's machine.
Avoid using Wscript and try your custom action again. Let me know how it went.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Re: Windows 7 64bit Registry Read Crash

Gabriel Hi,

Thanks for that, that executes if debug = true, the funny thing is, when I set debug = true and execute the vbs directly on the machine, it works fine.

As I say, it is during the install that it will not execute on that particular machine.

My gut feeling is there is something different with permissions on the machine during the install because as soon as an attempt to read the registry is done it crashes. Run the same vbs by double clicking and it is fine. The installer must be restricted in some way.

Cheers
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Windows 7 64bit Registry Read Crash

Hi,
Thanks for that, that executes if debug = true, the funny thing is, when I set debug = true and execute the vbs directly on the machine, it works fine.
You may have misunderstood my explanation. The Wscript object works fine when the vbscript is run directly. It will not work when the vbscript is executed as a custom action.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Re: Windows 7 64bit Registry Read Crash

Gabriel Hi,

I did understand your point and thank you for that. My point is, take it out and the problem is still there.

Thanks
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Windows 7 64bit Registry Read Crash

Hello,

If your vbscript requires admin rights, please make sure you have the "Deferred with no impersonation" option set for your custom action.
Other than that, I can only suggest you place Message Boxes in various places inside your script to determine which lines are reached and the exact line of code causing the installer to crash.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Re: Windows 7 64bit Registry Read Crash

Gabriel Thanks,

I have no option to set it to "Deferred with no impersonation" it is greyed out, the only option I can choose in the "Execution options" is Immediate Execution and it is selected by default.

All custom actions are like this, is there a global setting that affects this?

Many thanks for your help.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Windows 7 64bit Registry Read Crash

Hi,

The "Deferred with no impersonation" option can be used only for actions scheduled between InstallInitialize and InstallFinalize standard actions. Try moving your custom action so you can use this option.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Re: Windows 7 64bit Registry Read Crash

Thanks Cosmin

It's a UI Action action at the moment, I will have to re-work things.


Thanks
splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Re: Windows 7 64bit Registry Read Crash

cosmin wrote:Hi,

The "Deferred with no impersonation" option can be used only for actions scheduled between InstallInitialize and InstallFinalize standard actions. Try moving your custom action so you can use this option.

Regards,
Cosmin

Cosmin,

I have moved the action into the InstallExecuteSequence->Installinitialize and it is not running (on a machine that is ok)

As you can see from the VB Script, I use it to get values from the registry and then populate a combo box on the UI. I had it running on the "Next" button on the previous dialogue.

What event will allow me set the Deferred option and will run before the UI loads?

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

Re: Windows 7 64bit Registry Read Crash

Hi,

If you need the custom action in the UI, it shouldn't require Administrator privileges. You can try splitting the code in two custom actions:
- one in UI which reads data and updates the combo
- another one which performs the operations that require Administrator privileges (this one should run as Deferred with no impersonation)

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Re: Windows 7 64bit Registry Read Crash

Cosmin,

That's the issue..
- one in UI which reads data and updates the combo
The reading of data is where it crashes as it is querying the registry.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Windows 7 64bit Registry Read Crash

Hi,

Can you please try using message boxes to debug your custom action. If you can determine where exactly the error occurs, perhaps we can find a solution. I noticed that you are temporarily modifying the MSI to populate the combo. Please note that Advanced Installer has predefined actions for populating combo boxes.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
splay
Posts: 58
Joined: Tue May 15, 2007 6:09 pm

Re: Windows 7 64bit Registry Read Crash

Can you please try using message boxes to debug your custom action.
Cosmin, I have done this...

Code: Select all



Dim debug, debug_step_by_Step
debug = false
debug_step_by_Step = false

Dim is_CTI_Install ' Dont show errors for local CRM install as they may be installing the client on the machine

is_CTI_Install = false

If Not debug then
	Dim db
	Set db = Session.Database
End If

If Debug then
	get_names
End IF


Function get_names()

	If Not debug then
		If Session.Property("AI_BUILD_NAME") = "CTI" Then
			is_CTI_Install = True
		End IF
	End If
	
	
	get_names = 1
	
	Const HKEY_LOCAL_MACHINE = &H80000002

	strComputer = "."
   IF debug_step_by_Step Then MsgBox  "Line 34 - Pre GetObject", 65, "Error"	
	Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
   IF debug_step_by_Step Then MsgBox  "Line 36 - Post GetObject", 65, "Error"	 
	If Not is_64_bit Then
		strKeyPath = "Software\eWare\Mappings"
	Else
		strKeyPath = "Software\Wow6432Node\eWare\Mappings"
	End IF
	
	'on error resume next	
    IF debug_step_by_Step Then MsgBox  "Line 44 - Pre Reg.EnumValues", 65, "Error"	
        oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes
    IF debug_step_by_Step Then MsgBox  "Line 46 - Post Reg.EnumValues", 65, "Error"
    Dim reg_error
	reg_error = "The installer cannot find a version of Sage CRM on this machine." &_
				vbCrLf & "Please ensure you have a licensed version of CRM installed on this machine before proceeding."
	
	If Err.Number > 0 Then
		If NOT is_CTI_Install Then
			Session.Property( "CRM_INSTALL_CHECK" ) = "0"
			MsgBox  reg_error, 65, "Error"	
			get_names = -1
		End If
	Else
            If Not debug Then
		Session.Property( "CRM_INSTALL_CHECK" ) = "1"
            End IF
	End If
	
	
	If UBound(arrValueNames) < 0 Then
		If NOT is_CTI_Install Then
			Session.Property( "CRM_INSTALL_CHECK" ) = "0"
			get_names = -1
			MsgBox  reg_error, 65, "Error"
		End IF
		If Debug Then
			WScript.Echo "UBound(arrValueNames) < 0"
		End If
	Else
            If Not debug Then
		Session.Property( "CRM_INSTALL_CHECK" ) = "1"
            End IF
	End If
	
	index = 1

    IF debug_step_by_Step Then MsgBox  "Line 77 - Pre For i=0 To UBound(arrValueNames)", 65, "Error"		
	For i=0 To UBound(arrValueNames)

	    	'Wscript.Echo "File Name: " & arrValueNames(i) & " -- "  
		
	   	'Wscript.Echo "Location: " & strValue
	    	'Wscript.Echo

		    install_name = arrValueNames(i) 
    IF debug_step_by_Step Then MsgBox  "Line 86 - For i=0 To UBound(arrValueNames) - Pre oReg.GetStringValue - Loop " & i, 65, "Error"	    	
                oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath, arrValueNames(i), path
    IF debug_step_by_Step Then MsgBox  "Line 88 - For i=0 To UBound(arrValueNames) - Post oReg.GetStringValue - Loop " & i, 65, "Error"    
		
		
			' stick them into the combo
			
			If Instr( install_name, "/" ) > 0 then
				
				    install_name = Replace( install_name, "/", "") 
			        SQLCmd = "INSERT INTO `ComboBox` (`Property`,`Order`,`Value`,`Text`)"
			    	SQLCmd = SQLCmd & " VALUES ('CRM_NAME','" &  index & "','" & install_name & "','"
			    	SQLCmd = SQLCmd & install_name & "') TEMPORARY"
                                
                                If Not debug Then
                                    Set view = db.OpenView( SQLCmd )
        IF debug_step_by_Step Then MsgBox  "Line 100 - For i=0 To UBound(arrValueNames) - Pre view.Execute - Loop " & i, 65, "Error"			    	
                                    view.Execute
        IF debug_step_by_Step Then MsgBox  "Line 102 - For i=0 To UBound(arrValueNames) - Post view.Execute - Loop " & i, 65, "Error"	
                                    view.Close
                                    
				Else
					Wscript.Echo install_name
				End If
				
				index = index + 1

			End IF
		
	
	Next
	
	
End  Function

Function is_64_bit()

	 const HKEY_LOCAL_MACHINE = &H80000002
	 strComputer = "."
IF debug_step_by_Step Then MsgBox  "Line 123 - is_64_bit() Function - Pre oReg=GetObject", 65, "Error"	
	 Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
	  strComputer & "\root\default:StdRegProv")
IF debug_step_by_Step Then MsgBox  "Line 126 - is_64_bit() Function - Post oReg=GetObject", 65, "Error"	
	 strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
	 strValueName = "PROCESSOR_ARCHITECTURE"
IF debug_step_by_Step Then MsgBox  "Line 129 - is_64_bit() Function - Pre oReg.GetStringValue", 65, "Error"	
	 oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
IF debug_step_by_Step Then MsgBox  "Line 131 - is_64_bit() Function - Post oReg.GetStringValue", 65, "Error"
	 'WScript.Echo "Current Processor Archiecture: " & strValue
	  
	  Dim pos
		 pos = InStr( strValue, "64" ) 
		 If pos = 0 Then
			is_64_bit = False
		 Else
			is_64_bit = True
		 End If
 
End Function

Not one alert has popped up, tested on the machine in question and an ok machine.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Windows 7 64bit Registry Read Crash

Hi,

Did you check the registry permissions for the entries you are reading? Also, can you please send us a verbose log of the installation with the problem to support at advancedinstaller dot com so we can investigate it?

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

Return to “Common Problems”