Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Custom action using VbScript


7 replies to this topic

felixmat

felixmat
  • Full Members
  • 18 posts

Posted 04 December 2007 - 21:17

Hi

I am running IS 12.
I have a custom action that is written in VbScript. I basically need to get the Host name and the IP of the machine and assign it to variables in the script.

For Custom action dll's written in C, I have used MsiGetProperty to do this for me. How can I do the equivalent in VbScript? Do I need to package something? pls help.

Thanks !



KathyMorey

KathyMorey
  • Full Members
  • 111 posts

Posted 05 December 2007 - 14:52

Dim IPAddress

IPAddress = Session.Property("IPAddress")
Kathy Morey
Synergy Software Engineer
ProfitStars, a Jack Henry Company
kmorey@profitstars.com

felixmat

felixmat
  • Full Members
  • 18 posts

Posted 05 December 2007 - 22:19

Hi

I am running across the below error when I integrate the script into the installer. I basically created a new Custom Action using New VbScript> Stored in Binary table and linked the script. Pls Help!

Action start 15:19:17: checkHNameChange.
MSI © (8C:CC) [15:19:17:578]: Entering MsiProvideComponentFromDescriptor. Descriptor: T%i&7oT-C?kaTW(0fqX8Toolbox>M5KDYSUnf(HA*L[xeX)y, PathBuf: F22F2D8, pcchPathBuf: F22F2D4, pcchArgsOffset: F22F22C
MSI © (8C:CC) [15:19:17:578]: MsiProvideComponentFromDescriptor called for component {997FA962-E067-11D1-9396-00A0C90F27F9}: returning harcoded oleaut32.dll value
MSI © (8C:CC) [15:19:17:578]: MsiProvideComponentFromDescriptor is returning: 0
MSI © (8C:CC) [15:19:18:937]: Note: 1: 1720 2: checkHNameChange 3: -2146827864 4: Microsoft VBScript runtime error 5: Object required: 'WScript' 6: 115 7: 3
Info 1720.There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action checkHNameChange script error -2146827864, Microsoft VBScript runtime error: Object required: 'WScript' Line 115, Column 3,
Action ended 15:19:18: checkHNameChange. Return value 1.

KathyMorey

KathyMorey
  • Full Members
  • 111 posts

Posted 06 December 2007 - 13:54

Can you post your script?

Edited by KathyMorey, 06 December 2007 - 13:55.

Kathy Morey
Synergy Software Engineer
ProfitStars, a Jack Henry Company
kmorey@profitstars.com

felixmat

felixmat
  • Full Members
  • 18 posts

Posted 06 December 2007 - 16:23

Hi Kathy....Below is a snippet of the script, it is a big script so i have not posted the whole thing but its head and the portion where the script fails. You would see that WScript.echo is being used and thats where is fails....pls. let me knwo if you need any other info

g_curHost = ""
g_curIP = ""
g_origHost = ""
g_hostNameChecked = False
g_multiServiceChecked = False
g_exitVal = -1
g_XXXXSERVICE = ""

'**************************************
g_strUser = ""
g_strPassword = ""

'**************************************

Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7

Const INT_SLEEP = 5000

Const EXIT_NO_MISMATCH = 0
Const EXIT_UPDATE_SUCCESS = 0
Const EXIT_ERR_SETTING_OR_HOST = 1
Const EXIT_ERR_SETTING_CUR_HOST = 2
Const EXIT_ERR_CREATING_KEY = 3
Const EXIT_ERR_COPYING_KEYVAL = 4
Const EXIT_ERR_REPL_HOSTNAME = 5
Const EXIT_ERR_MULTIPLE_SERVICE = 6
Const EXIT_ERR_STOPPING_SERVICE = 7
Const EXIT_ERR_CREATING_SERVICE = 8
Const EXIT_ERR_DELETING_SERVICE = 9
Const EXIT_ERR_STARTING_SERVICE = 10
Const EXIT_ERR_SERVICE_NOTFOUND = 11
Const EXIT_ERR_NODELIST_NOTFOUND = 12


Const REG_ROOT = 0
Const REG_ENUM = 1
Const REG_SECUR = 2

Const SCP = "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
Dim objDelReg
Dim node

'g_strUser = "xxxxxxxxxx"
'g_strPassword = "xxxxxxxx"
'createService " xxxxxxxxxx"


'Set objArgs = WScript.Arguments
'node = Trim(objArgs(0))
'setCurIP node
'g_strUser = Trim(objArgs(1))
'g_strPassword = Trim( objArgs(2) )


GetAProperty()
executeUpdate()


'*********************************************************
' Purpose: Get Node properties from the installer
'*********************************************************

Sub GetAProperty
'node = Session.Property("ComputerName")

End Sub

'*********************************************************
' Purpose: Starting point for the script
'
' Inputs: NA
'
' Returns: NA
'*********************************************************
Sub executeUpdate
If Len(node) > 1 Then
'WScript.Echo "HOSTNAME UPDAT: processing node: " & node
setCurHost(node)

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
'Set oServiceDel = objSWbemLocator.ConnectServer(getCurIP(), _
' "root\default", _
' g_strUser, _
' g_strPassword, _
' "MS_409", _
' "")

'oServiceDel.Security_.ImpersonationLevel = 3


'Set objDelReg = oServiceDel.Get("StdRegProv")

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

processService()
processNonService()
Else
'WScript.Echo "HOSTNAME UPDAT: no node has been defined on the command line." & vbCrLf
'WScript.Echo SCP & vbCrLf & SCP & vbCrLf
WScript.Quit
End If
End Sub

felixmat

felixmat
  • Full Members
  • 18 posts

Posted 06 December 2007 - 18:13

Hi Kathy I was able to get around the first error by adding

Set WshShell = CreateObject("WScript.Shell") to my script ....but now am now across teh below

Action 12:05:48: checkHNameChange.
Action start 12:05:48: checkHNameChange.
MSI © (C0:F8) [12:05:48:703]: Entering MsiProvideComponentFromDescriptor. Descriptor: T%i&7oT-C?kaTW(0fqX8Toolbox>M5KDYSUnf(HA*L[xeX)y, PathBuf: F22F2D8, pcchPathBuf: F22F2D4, pcchArgsOffset: F22F22C
MSI © (C0:F8) [12:05:48:703]: MsiProvideComponentFromDescriptor called for component {997FA962-E067-11D1-9396-00A0C90F27F9}: returning harcoded oleaut32.dll value
MSI © (C0:F8) [12:05:48:703]: MsiProvideComponentFromDescriptor is returning: 0
MSI © (C0:F8) [12:05:49:078]: Note: 1: 1720 2: checkHNameChange 3: -2146827850 4: Microsoft VBScript runtime error 5: Object doesn't support this property or method: 'WshShell.Echo' 6: 118 7: 3
Info 1720.There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action checkHNameChange script error -2146827850, Microsoft VBScript runtime error: Object doesn't support this property or method: 'WshShell.Echo' Line 118, Column 3,
Action ended 12:05:49: checkHNameChange. Return value 1.

KathyMorey

KathyMorey
  • Full Members
  • 111 posts

Posted 07 December 2007 - 13:55

I'm not an expert,but I believe that Windows Installer is its own scripting host, and doesn't support the WScript object.
Kathy Morey
Synergy Software Engineer
ProfitStars, a Jack Henry Company
kmorey@profitstars.com

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 10 December 2007 - 00:20

According to the log you've got a variable called "WshShell" and on line 118 you're calling its method "Echo". Although the variable is indeed an object, it does not support a method called "Echo".

Assuming that the variable was created with CreateObject("WScript.Shell"), then that object indeed will not have such a method. Try calling another method that is supported, like Popup or Exec.

Here is the doc of that particular object:
http://msdn2.microso...y/aew9yb99.aspx