Solved

How do I resolve a "Microsoft VBScript runtime error 800a01c2 Wrong number of arguments or invalid property assignment" error?

Posted on 2010-09-15
4
2,532 Views
Last Modified: 2012-05-10
I am trying to run a VBScript and when it executes, I get the following error message, "ChainedInstall.vbs (147, 2) Microsoft VBScript runtime error:  Wrong number of arguments or invalid property assignment: 'CollectAndCleanUp'.  I am not a VBscript expert so I do not know how to resolve this.  I found this script on the web and made the changes as instructed in the script.  Please assist.

'-----------------------------------------------------------------
' IBM Lotus Notes Chained Install Example script
' 
' Copyright IBM Corp. 2010
'
' This program is distributed in the hope that it will be useful, but
' WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
'
' Written by J. Mitchell, S. Williams
'-----------------------------------------------------------------
'
' This script is intended to be an example of how to chain two Lotus Notes
' installations together for use with SmartUpgrade. It assumes the installation
' kits are on a network share. It also takes 1 optional parameter when invoked.
'    -v which turns on verbose logging in the Notes installer

Const strScriptVersion = "1.001" ' bump this with every release


' Te following constants are the locations of the Notes install kits and should be changed for your environment
' Format of package path strings = \\<server_name>\<share>\<path to install kit setup.exe>
'   the Notes install kit path should point to the setup.exe of a Notes Fix Pack kit
'   the Sametime 8.5 Add On install path should point to the setup.exe of a Sametime embedded Add On install kit.
' If starting with a single install file such as sametime.embedded.add-on.win.<timestamp>.exe, then execute the
' file locally and choose the option to expand the files to a temp folder, then cancel when the install begins to run.

Const strInstallPackagePath_1 = "Y:\ND852\ND852All\setup.exe" 
Const strInstallPackagePath_2 = "Y:\ND852\ST851ADDON\setup.exe"

Const strInstallPackageName_1 = "Notes 8.5.2 All Clients" 
Const strInstallPackagename_2 = "Sametime 8.5.1"


' Notes processes we kill
arrPrograms = array("'notes2.exe'", "'notes2w.exe'", "'notes.exe'", "'nlnotes.exe'", "'ntmulti.exe'", "'ntaskldr.exe'")

' Eclipse process we kill more descriminately
strEclipse = "'eclipse.exe'"
strFingerprint = "ibm.notes.branding.notes"

' values used for process watching 
Const timeout  = 999900000	'in millisecond
Const timepoll = 500    	'in millisecond

' values use in regsitry cleaning
Const HKCU = &H80000001 
Const HKLM = &H80000002

'SetupX_1 and SetupX_2 are the exec object for the first and second setup
Dim SetupX_1, SetupX_2
Dim strProgPath 'stores the registry to point to the Lotus Notes installation path.

Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell")
Dim SVC      : Set SVC = GetObject("winmgmts:root\cimv2")
Dim FSO      : Set FSO = CreateObject("Scripting.FileSystemObject")
Dim REG	     : Set REG = GetObject("winmgmts:\\.\root\default:StdRegProv") 

'Collect all the logs and information to the %TEMP%\IBM_Logs_<DATE> directory for easy finding later
If Month(Now) < 10 Then
   months = "0" & Month(Now) ' make it look nice with a leading 0
End If
LogDir = WshShell.ExpandEnvironmentStrings("%temp%") & "\IBM_Logs_" & months & "" & Day(Now) & "\"

If Not FSO.FolderExists(LogDir) Then 
   FSO.CreateFolder(LogDir)
End If

'Setup log file to track progress and time the upgrade.
Set LogStream = FSO.CreateTextFile(LogDir &"Notes_ChainedInstall.txt" , True)

' Write a header to the log
LogStream.WriteLine(Now & ": Starting Lotus Notes Chained installation script (Version " & strScriptVersion & ")")
LogStream.WriteLine(Now & ": WSH Version " & wscript.Version)

' make sure we have valid pre-populated area to run installation kits from
If Not FSO.FileExists(strInstallPackagePath_1) Then
   LogStream.WriteLine(Now & ": The " & strInstallPackageName_1 & " install kit was not found at " & strInstallPackagePath_1)
   wScript.Echo("The " & strInstallPackageName_1 & " installer files are missing. Please contact the Help Desk")
   wScript.Quit(255)
End If

If Not FSO.FileExists(strInstallPackagePath_2) Then
   LogStream.WriteLine(Now & ": The " & strInstallPackageName_2 & " install kit was not found at " & strInstallPackagePath_1)
   wScript.Echo("The " & strInstallPackageName_2 & " installer files are missing. Please contact the Help Desk")
   wScript.Quit(255)
End If

' check if the current user is an admin by checking if they can see the Admin$ share
' comment this part out if using SURunAs or running with elevated privledges
If Not FSO.FolderExists("\\" & WshShell.ExpandEnvironmentStrings("%computername%") & "\Admin$\System32") Then 
    LogStream.WriteLine(Now & ": The user is not a local admin on this machine: " & WshShell.ExpandEnvironmentStrings("%COMPUTER%"))
    wScript.Echo("You are not an Administrator of this machine.  Please contact the Help Desk.")
    wScript.Quit(255)
End If

' Look for and terminate any lingering Notes/Eclipse processes
For Each Program In arrPrograms
   Set colProcessList = SVC.ExecQuery ("Select * from Win32_Process Where Name = " & Program)
   For Each objProcess in colProcessList
      objProcess.Terminate()
   LogStream.WriteLine(Now & ": Terminated " & objProcess.Name) 
   Next
Next
' Find the process
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}").ExecQuery ("SELECT * FROM Win32_Process Where Name = " & strEclipse)

' Determine if its ours and if so terminate it
For Each objProcess In objWMIService
    If (InStr(objProcess.CommandLine, strFingerprint) > 0) Then
        objProcess.Terminate()
        LogStream.WriteLine(Now & ": Terminated " & objProcess.Name)
    End If
Next

' Look for and close the lingering java debug crash dialog box
if (WshShell.AppActivate("IBM Lotus Notes")) Then
   ' found it so send it the Enter key to make it go away
   wshShell.SendKeys("{ENTER}")
   LogStream.WriteLine(Now & ": Found the java crash dialog box and closed it.")
End if

' Read the Notes installation path from the registry, this will cause a error msg box if the reg key does not exist (aka Notes is not installed)
On Error Resume Next
strProgPath = WshShell.RegRead("HKLM\Software\Lotus\Notes\Path")
LogStream.WriteLine(Now & ": Notes program folder from registry = " & strProgPath)
strMultiUser = wshShell.RegRead("HKLM\Software\Lotus\Notes\MultiUser")
If (Not IsEmpty(strMultiUser)) And (strMultiuser = 1) Then
	strDataPath =  wshShell.RegRead("HKCU\Software\Lotus\Notes\7.0\NotesIniPath")
	' remove the notes.ini from the end of the value retrieved
	strDataPath = "" & Left(strDataPath,Len(strDataPath) - Len("notes.ini"))
Else
	strDataPath = wshShell.RegRead("HKLM\Software\Lotus\Notes\DataPath")
End If
LogStream.WriteLine(Now & ": Notes data folder from registry = " & strDataPath)
On Error GoTo 0

If Not IsEmpty(strProgPath) Then
    ' Notes was found in the registry but it's probably not 7.0.x  check to see if it's 8.5.1
    On Error Resume Next
    strNotesVer = WshShell.RegRead("HKLM\Software\Lotus\Notes\Version")
    On Error GoTo 0
    If Not IsEmpty(strNotesVer) Then
	LogStream.WriteLine(Now & ": Found Notes version " & strNotesVer)
    Else
        LogStream.WriteLine(Now & ": Found unknown version of Notes in registry running collect and cleanup")CollectAndCleanUp
    End If
Else
	LogStream.WriteLine(Now & ": Notes not found in registry, assuming a clean machine.")
End If
set cproc=nothing

'Notes was not in the registry or we've just cleaned it up. moving right along...

'Check a command line option to determine if the install will include verbose logging.  
'To enable the verbose logging enter -V or -v as the first command line argument when launching this script.
If Wscript.Arguments.Count > 0 then Verbose = WScript.Arguments(0)  'set first command line arg to Verbose - used to enable logging
If LCase(Verbose) = "-v"  then ' If verbose is -v then get verbose logging to the users temp directory
    LogStream.writeline(Now & ": Verbose logging is enabled for Notes 8.5.1 FP2 and Sametime 8.5 installations.")
    LogStream.writeline(Now & ": Verbose logs can be found in the " & LogDir & " directory.")

    strSetupCmd_1 = strInstallPackagePath_1 & " /s /v" & chr(34)&"/l*v " & LogDir &"notes851_FP2_install.txt /qb!" & chr(34)
    strSetupCmd_2 = strInstallPackagePath_2 & " /s /v" & chr(34)&"/qb /liwae " & LogDir & "sametime85_install.txt" & chr(34)
Else
    strSetupCmd_1 = strInstallPackagePath_1 & " /s /v" & chr(34)&"/qb!" & chr(34)
    strSetupCmd_2 = strInstallPackagePath_2 & " /s /v" & chr(34)&"/qb!" & chr(34)
End If	



'Launch the first setup
LogStream.WriteLine(Now & ": Lauching " & strInstallPackageName_1 & " installation") 
Set SetupX_1 = WshShell.Exec(strSetupCmd_1)
LogStream.WriteLine(Now & ":    Running " & strSetupCmd_1)


' Sleep a bit before starting to monitor the process
wScript.Sleep(5000)


' in the subcall below, parameter1 = process id, parameter2 = a generic string name of process used for logging
WaitForProcess SetupX_1,strInstallPackageName_1,true


' wait 10 seconds to give the notes2.exe process time to quit from the first install
wScript.Sleep(10000)


'Launch the second install
LogStream.WriteLine(Now & ": Launching " & strInstallPackagename_2 & " installation")
Set SetupX_2 = WshShell.Exec(strSetupCmd_2)
LogStream.WriteLine(Now & ":    Running " & strSetupCmd_2)

' in the subcall below, parameter1 = process id, parameter2 = a generic string name of process used for logging
WaitForProcess SetupX_2,strInstallPackageName_2,false

LogStream.WriteLine(Now & ": Installation completed ")
LogStream.WriteLine(Now & ": The installation completed with a final exit code of: " & Err)

If Err <> 0  then ' If we end with an error, provide a description.
    LogStream.WriteLine("The install failed with error: " & Err.Description)
End If

LogStream.Close



Function WaitForProcess(Process,strName,bCleanUp)
    sQuery="select * from win32_process where ProcessID=" & Process.ProcessID & ""

    For i=0 to timeout\timepoll   'Monitor the process and wait until the process exits.
        Set cproc=SVC.execquery(sQuery)

        If cproc.count=0 Then    'this monitor all instances died out
            LogStream.WriteLine(Now & ": " & strName & " completed with return code: " & Process.ExitCode)
            If Not (Process.ExitCode) = 0 Then
                ' process did not complete successfully, collect the logs and clean the machine
                If Not (bCleanup = -1) Then
                   CollectAndCleanUp(bCleanUp)
                End If
                ' Notify the user and then quit out of the script
                WScript.Echo("The " & strName & " installation failed.  Please contact the Help Desk.")
                LogStream.Close
                wScript.Quit(SetupX_1.ExitCode)	
            End If
            ' The 851 install finished ok its time to 
            Exit For
   	Else
            If i=timeout\timepoll Then
                LogStream.WriteLine(Now & ": " & strName & " installation took longer than " &  timeout\1000*60 & " minutes.")
                wScript.Echo("The "& ": " & strName & " installation is taking longer than expected.  Please contact the Help Desk.")
                LogStream.Close
                wScript.Quit(255)	
            Else
                wScript.Sleep(timepoll) 'sleep while we wait for setup to finish
            End if
	End if
    Next
    Set cproc=nothing
End Function


Function CollectAndCleanUp(DoCleanup)
    LogStream.WriteLine(Now & ": Entered Collect and Clean Up")

    On Error Resume Next
    ' Refead the Notes installation path from the registry, it might have just been installed
    strProgPath = WshShell.RegRead("HKLM\Software\Lotus\Notes\Path")
    LogStream.WriteLine(Now & ": Notes program folder from registry = " & strProgPath)
    strMultiUser = wshShell.RegRead("HKLM\Software\Lotus\Notes\MultiUser")
    If (Not IsEmpty(strMultiUser)) And (strMultiuser = 1) Then
        strDataPath =  wshShell.RegRead("HKCU\Software\Lotus\Notes\7.0\NotesIniPath")
        ' remove the notes.ini from the end of the value retrieved
        strDataPath = "" & Left(strDataPath,Len(strDataPath) - Len("notes.ini"))
    Else
        strDataPath = wshShell.RegRead("HKLM\Software\Lotus\Notes\DataPath")
    End If
    LogStream.WriteLine(Now & ": Notes data folder from registry = " & strDataPath)
    LogStream.WriteLine(Now & ":    Collecting log files into " & LogDir)
    
    FSO.CreateFolder(LogDir & "workspace\")
    FSO.CopyFolder strDataPath & "workspace\logs",LogDir & "workspace\logs",true

    FSO.CreateFolder(LogDir & "workspace\.config")
    FSO.CopyFile strDataPath & "workspace\.config\*", LogDir & "workspace\.config",true

    FSO.CreateFolder(LogDir & "workspace\.configbak")
    FSO.CopyFile strDataPath & "workspace\.configbak\*", LogDir & "workspace\.configbak",true

    FSO.CreateFolder(LogDir & "workspace\.config\org.eclipse.update")
    FSO.CopyFile strDataPath & "workspace\.config\org.eclipse.update\*", LogDir & "workspace\.config\org.eclipse.update",true

    FSO.CreateFolder(LogDir & "workspace\.configbak\org.eclipse.update")
    FSO.CopyFile strDataPath & "workspace\.configbak\org.eclipse.update\*", LogDir & "workspace\.configbak\org.eclipse.update",true

    FSO.CreateFolder(LogDir & "workspace\.metadata")
    FSO.CreateFolder(LogDir & "workspace\.metadata\.plugins")
    FSO.CopyFolder strDataPath & "workspace\.metadata\.plugins\org.eclipse.core.runtime", LogDir & "workspace\.metadata\.plugins\org.eclipse.core.runtime",true

    FSO.CreateFolder(LogDir & "framework\")
    FSO.CopyFile strProgPath & "framework\*", LogDir & "framework",true

    FSO.CreateFolder(LogDir & "framework\rcp")
    FSO.CopyFile strProgPath & "framework\rcp\*", LogDir & "framework\rcp",true

    FSO.CreateFolder(LogDir & "framework\rcp\deploy")
    FSo.CopyFile strProgPath & "framework\rcp\deploy\*", LogDir & "framework\rcp\deploy",true

    FSO.CreateFolder(LogDir & "framework\rcp\deploy\kitHistory")
    FSo.CopyFile strProgPath & "framework\rcp\deploy\kitHistory\*", LogDir & "framework\rcp\deploy\kitHistory",true 

    FSO.CopyFile WshShell.ExpandEnvironmentStrings("%temp%") & "\rcplauncher.log",LogDir,true
    FSO.CopyFile WshShell.ExpandEnvironmentStrings("%temp%") & "\rcpinstallertemp.properties",LogDir,true

    On Error GoTo 0

    ' grab the directory listing for the workspace and framework directories
    If FSO.FolderExists(strDataPath & "workspace") Then 
        Set workspace_list = FSO.CreateTextFile(LogDir &"workspace_list.txt" , true)
        ListDirectoryContents fso.GetFolder(strDataPath & "workspace"),workspace_list 
        workspace_list.Close
    Else
        LogStream.WriteLine(Now & ": No workspace directory found at " & cstrDataPath)
    End If

    If FSO.FolderExists(strProgPath & "framework") Then 
        Set framework_list = FSO.CreateTextFile(LogDir &"framework_list.txt" , true)
        ListDirectoryContents fso.GetFolder(strProgPath & "framework"),framework_list 
        framework_list.Close
    Else
        LogStream.WriteLine(Now & ": No framework directory found at " & cstrProgPath)
    End If

    ' Collections all done, time to clean up
    LogStream.WriteLine(Now & ":    Collection finished")
        
    If (DoCleanUp) Then
        LogStream.WriteLine(Now & ":    Starting Clean up")

        If FSO.FolderExists(strDataPath) Then
            ' NSD needs to run from the users data directory at this time
            WshShell.CurrentDirectory = strDataPath

            ' Launch NSD
            strNSDCmd = strProgPath & "nsd.exe -dumpandkill -batch"
            Set NSDx = WshShell.Exec(strNSDCmd)
            LogStream.WriteLine(Now & ": Launched " & strNSDCmd)
            
            WaitForProcess NSDx,"NSD -kill",-1

            'grab the latest NSD logs just to be crazy careful
            FSO.CreateFolder(LogDir & "nsd_logs")
            FSO.CopyFile strNotesData & "IBM_TECHNICAL_SUPPORT\*.log", LogDir & "nsd_logs",true
        End If
       	On Error Resume Next
        
        LogStream.WriteLine(Now & ": Cleaning up the registry")
        DeleteSubkeys HKLM, "Software\Lotus\Notes"
        DeleteSubKeys HKLM, "Software\IBM\Lotus\Expeditor"
        DeleteSubKeys HKCU, "Software\Lotus\Notes"

        ' remove the folders
        LogStream.WriteLine(Now & ": Cleaning up the framework directory")
        FSO.DeleteFolder strProgPath & "framework",true 
        LogStream.WriteLine(Now & ": Cleaning up the workspace directory")
        FSO.DeleteFolder strDataPath & "workspace", true
        On Error GoTo 0
    End If
    Logstream.WriteLine(Now & ": Exiting Collect and Clean Up")
End Function


'# Recursively search the directory provided
Function ListDirectoryContents(directory,listfile)

  '# If it is a directory search again
  For Each subDirectory In directory.SubFolders
    ListDirectoryContents subDirectory,listfile
  Next

  '# If it is a file check to see that it matches the conditions
  For Each file In directory.Files
	listfile.WriteLine(file.path)
  Next
End Function



Function DeleteSubkeys(Hive, strKeyPath) 
    REG.EnumKey Hive, strKeyPath, arrSubkeys 

    If IsArray(arrSubkeys) Then 
        For Each strSubkey In arrSubkeys 
            DeleteSubkeys Hive, strKeyPath & "\" & strSubkey 
        Next 
    End If 

   REG.DeleteKey Hive, strKeyPath 
End Function

Open in new window

0
Comment
Question by:niccilaw
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
ID: 33681869
Looks like this line is the problem:

LogStream.WriteLine(Now & ": Found unknown version of Notes in registry running collect and cleanup")CollectAndCleanUp


Should CollectAndCleanUp be there after the right parentheses?

0
 
LVL 28

Expert Comment

by:omgang
ID: 33681878
The script is calling the CollectAndCleanUp function and passing it the parameter bCleanup BUT bCleanup is not declared nor instantiated anywhere in the script.  Is some of the script missing or has anything been removed?
OM Gang
0
 
LVL 28

Expert Comment

by:omgang
ID: 33681937
DanZel, good point.  The CollectAndCleanUp function has a non-optional parameter (should be boolean) that needs to be passed to it.  Perhaps that call was originally on a seperate line and had a parameter assignment with it?

niccilaw, if you found this script on the web it's possible the code was a bit jumbled in the html of the page you found it on.
OM Gang
0
 

Author Comment

by:niccilaw
ID: 33681990
Dan7el.  You are correct.  I removed the CollectAndCleanUp after the right parenthesis and the script ran successfully.  Thanks.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question