xzay1967
asked on
Help solve my code
I am lost in this script, I am getting end of statement needed error
'===============================================================
'=== Health Partners Scripting / Packaging VBScript Template
'=== Author: Bobby Lee
'===
'=== Revision History:
'=== 09/04/2012: v1.0 - Initial Release
'===
'===============================================================
Const OverwriteExisting = True
Const HKEY_LOCAL_MACHINE = &H80000002
'Const HKEY_CLASSES_ROOT = &H80000000
'Const HKEY_CURRENT_USER = &H80000001
'Const HKEY_USERS = &H80000003
Dim objIEDebugWindow
Dim objFSO, objFolder, WshShell, objTextFile, objFile, oReg
Dim Scanner_File, Scanner_File2, strComputer
Dim appName, appVer, logfile, Bit32_64, ReturnCode, ReturnCode_Err
Dim strDirectory, Log_File, strText, strKeyPath, strValueName, strValue
Dim strPath, strScriptFolder, strCommand, strScriptPath, strScriptFullName
Dim strEnv, strMode, strLD
'=========================
'=== Script Parameters ===
'=========================
Set colNamedArguments = WScript.Arguments.Named
If colNamedArguments.Exists("Env") Then
strEnv = UCase(colNamedArguments.Item("Env"))
Else
strEnv = "Prod"
End If
If colNamedArguments.Exists("Mode") Then
strMode = UCase(colNamedArguments.Item("Mode"))
Else
strMode = "INSTALL"
End If
If colNamedArguments.Exists("LD") Then
strLD = UCase(colNamedArguments.Item("LD"))
Else
strLD = "9"
End If
'===============================
'=== Application Information ===
'===============================
appName = "CCPulse"
appVer = "v8.0100.16"
strComputer = "." 'Use . for current machine
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set colNamedArguments = WScript.Arguments.Named
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
'============================
'=== Get Script Directory ===
'============================
strPath = WScript.ScriptFullName
Set objFile = objFSO.GetFile(strPath)
strScriptFolder = objFSO.GetParentFolderName(objFile) & "\"
'WScript.Echo strScriptFolder
'==========================
'=== Log File Directory ===
'==========================
strDirectory = "c:\logs\appinst"
Log_File = strDirectory & "\" & appName & " " & appVer & "_Inst"& ".log"
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
'WScript.Echo "Created Directory: " & strDirectory
End If
If objFSO.FileExists(Log_File) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile(Log_File)
'Wscript.Echo "Created Logfile: " & Log_File
End If
Set objFile = Nothing
Set objFolder = Nothing
'=== End Log File Declaration ===
'===============================================
'=== OpenTextFile Method needs a Const value ===
'=== ForAppending = 8 ===
'=== ForReading = 1 ===
'=== ForWriting = 2 ===
'===============================================
Const ForAppending = 8
'==============================
'=== Initialize Error Codes ===
'==============================
ReturnCode = 0
ReturnCode_Err = 0
'===================================
'=== Begin - Initialize Log File ===
'===================================
Set objTextFile = objFSO.OpenTextFile(Log_File, ForAppending, True)
objTextFile.WriteLine("=====================================================")
objTextFile.WriteLine(Now & ": Begin Execution")
objTextFile.WriteLine(Now & ": LogFile = " & Log_File)
'=== End Initialize Log File ===
'=== Determine 32-bit or 64-bit OS
strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
strValueName = "PROCESSOR_ARCHITECTURE"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,Bit32_64
'Debug "This is a great way to display intermediate results in a separate window."
'============================
'=== Begin Common Section ===
'============================
objTextFile.WriteLine(Now & ": === Processing Common Section")
'=== Remove Registry Keys
'strKeyPath = "SOFTWARE\Microsoft\Active Setup\Installed Components\>{0000000000-0000-0000-0000-HP0000CCE1130}"
'strValueName = "Version"
'strValue = ReadRegStr (HKEY_LOCAL_MACHINE, strKeyPath, strValueName, 32)
'If not IsBlank(strValue) Then
' objTextFile.WriteLine(Now & ": Removing ActiveSetup Component from Registry for v11.30")
' oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath
'End If
'=== Enumerate Registry Key
'strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
'oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
'For Each objSubkey In arrSubkeys
' 'code here
'Next
'=== CCPulse v8.0.100.16?
'strValue = ""
'strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{4C321511-E6CA-4D0E-AC48-72AB7E7297A8}"
'strValueName = "DisplayVersion"
'strValue = ReadRegStr (HKEY_LOCAL_MACHINE, strKeyPath, strValueName, 32)
'WScript.Echo "CCPulse v8.0.100.16 in 32-bit registry " & strValue
'If IsBlank(strValue) Then
'WScript.Echo "Uninstalling CCPulse+ v8.0.100.16 in 32-Bit Registry: " & strValue
objTextFile.WriteLine(Now & ": Installing CCPulse+ v8.0.100.16")
strCommand = chr(34) & strScriptFolder & "Source\setup.exe" -s -f1 & chr(34) & strScriptFolder & "Source\setup.iss"" -f2""c:\logs\appinst\CCPulse_v8.0_Inst.log""",0,True)
ReturnCode = WshShell.Run(strCommand,0,True)
'ReturnCode = WshShell.Run("""\\hplandesk95\packages\CCPulse\v8\Source\setup.exe"" -s -f1""\\hplandesk95\packages\CCPulse\v8\Source\setup.iss"" -f2""c:\logs\appinst\CCPulse_v8.0_Inst.log""",0,True)
objTextFile.WriteLine(Now & ": Return Code = " & ReturnCode)
objTextFile.WriteLine(" ")
'oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath
InstallError (ReturnCode)
'End If
If UCase(Bit32_64) = "X86" Then
'============================
'=== Begin 32-bit Section ===
'============================
'objTextFile.WriteLine(Now & ": === Processing 32-bit Section")
' #region Disabled code
' '=== CCE v12.20 Installed?
' strValue = ""
' strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{6377D733-85CF-4961-91CE-B84A4F866917}"
' '=== HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{6377D733-85CF-4961-91CE-B84A4F866917}
' strValueName = "DisplayVersion"
' strValue = ReadRegStr (HKEY_LOCAL_MACHINE, strKeyPath, strValueName, 32)
' 'oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
' 'WScript.Echo "CCE v12.20 in 32-bit registry " & strValue
' If IsEmpty(strValue) Or IsNull(strValue) Then
' 'WScript.Echo "Executing CCE v12.20 in 32-Bit Registry: " & strValue
' objTextFile.WriteLine(Now & ": Installing CCE v12.20")
' ReturnCode = WshShell.Run("""\\hplandesk95\packages\CCE\v12.20\Disk1\setup.exe"" -s -f1""\\hplandesk9\packages\CCE\v12.20\Disk1\setup.iss"" -f2""c:\logs\appinst\CCE_1220_ISS.log",0,True)
' objTextFile.WriteLine(Now & ": Return Code = " & ReturnCode)
' objTextFile.WriteLine(" ")
' 'InstallError (ReturnCode)
' Else
' objTextFile.WriteLine(" ")
' objTextFile.WriteLine(Now & ": Detected CCE " & strValue & " Installed")
' objTextFile.WriteLine(" ")
' End If
' Set strValue = Nothing
' #endregion
'=============
'=== Debug ===
'=============
' ReturnCode = 10
' objTextFile.WriteLine(Now & ": Debug")
' objTextFile.WriteLine(Now & ": Return Code = " & ReturnCode)
' objTextFile.WriteLine(" ")
' InstallError(ReturnCode)
'=== End 32-bit Section ===
Else
'============================
'=== Begin 64-bit Section ===
'============================
'objTextFile.WriteLine(Now & ": === Processing 64-bit Common Section")
'Set strValue = Nothing
'=== End 64-bit Section ===
End If
'=====================================================
'=== Begin Post-Installation Configuration Section ===
'================------===============================
objTextFile.WriteLine(Now & ": === Processing Post-Installation Configuration Section")
objTextFile.WriteLine("")
If objFSO.FolderExists("C:\GCTI\CCPulse+") Then
objFSO.CopyFile chr(34) & strScriptFolder & "Updates\*.stg" , "C:\GCTI\CCPulse+\" , OverwriteExisting
'objFSO.CopyFile "\\hplandesk95\packages\CCPulse\v8\Updates\*.stg" , "C:\GCTI\CCPulse+\" , OverwriteExisting
objTextFile.WriteLine(Now & ": Installing HP Custom Files: Return Code = " & ReturnCode)
End If
'=== Force LANDesk Inventory Scan
LDInventory()
objTextFile.WriteLine("===============================================")
objTextFile.Close
'=== End Post-Installation Configuration Section ===
'=== Cleanup ===
Set objFSO = Nothing
Set objFolder = Nothing
Set WshShell = Nothing
Set objTextFile = Nothing
Set objFile = Nothing
Set oReg = Nothing
Set appName = Nothing
Set appVer = Nothing
Set logfile = Nothing
Set Bit32_64 = Nothing
Set ReturnCode = Nothing
Set strDirectory = Nothing
Set Log_File = Nothing
Set strText = Nothing
Set strKeyPath = Nothing
Set strValueName = Nothing
Set strValue = Nothing
WScript.Quit
' Reads a REG_SZ value from the local computer's registry using WMI.
' Parameters:
' RootKey - The registry hive (see http://msdn.microsoft.com/en-us/library/aa390788(VS.85).aspx for a list of possible values).
' Key - The key that contains the desired value.
' Value - The value that you want to get.
' RegType - The registry bitness: 32 or 64.
Function ReadRegStr (RootKey, Key, Value, RegType)
Dim oCtx, oLocator, oReg, oInParams, oOutParams
Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", RegType
Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")
Set oInParams = oReg.Methods_("GetStringValue").InParameters
oInParams.hDefKey = RootKey
oInParams.sSubKeyName = Key
oInParams.sValueName = Value
Set oOutParams = oReg.ExecMethod_("GetStringValue", oInParams, , oCtx)
ReadRegStr = oOutParams.sValue
End Function
Sub InstallError (ReturnCode)
'=== Retain ReturnCode if error and exit script if required component
If ReturnCode <> 0 Then
objTextFile.WriteLine(Now & ": *** Installation Error Encountered ***")
objTextFile.WriteLine(Now & ": Return Code = " & ReturnCode)
objTextFile.Close
Set objFSO = Nothing
Set objFolder = Nothing
Set WshShell = Nothing
Set objTextFile = Nothing
Set objFile = Nothing
Set oReg = Nothing
Set appName = Nothing
Set appVer = Nothing
Set logfile = Nothing
Set Bit32_64 = Nothing
Set strDirectory = Nothing
Set Log_File = Nothing
Set strText = Nothing
Set strKeyPath = Nothing
Set strValueName = Nothing
Set strValue = Nothing
WScript.Quit(ReturnCode)
End If
End Sub
Sub LDInventory()
Scanner_File = "C:\Program Files (x86)\LANDesk\LDClient\LDISCN32.EXE"
Scanner_File2 = "C:\Program Files\LANDesk\LDClient\LDISCN32.EXE"
'ReturnCode = 0
If objFSO.FileExists (Scanner_File) Then
ReturnCode = WshShell.Run("""C:\Program Files (x86)\LANDesk\LDClient\LDISCN32.EXE"" /NTT=HPLANDESK9:5007 /S=HPLANDESK9 /I=HTTP://HPLANDESK9/ldlogon/ldappl3.ldz /NoUI /Sync /F",0,True)
ElseIf objFSO.FileExists (Scanner_File2) Then
ReturnCode = WshShell.Run("""C:\Program Files\LANDesk\LDClient\LDISCN32.EXE"" /NTT=HPLANDESK9:5007 /S=HPLANDESK9 /I=HTTP://HPLANDESK9/ldlogon/ldappl3.ldz /NoUI /Sync /F",0,True)
End If
objTextFile.WriteLine(Now & ": Return Code = " & ReturnCode & " : Updating LANDesk Inventory")
End Sub
Sub Debug( myText )
' Uncomment the next line to turn off debugging
Exit Sub
If Not IsObject( objIEDebugWindow ) Then
Set objIEDebugWindow = CreateObject( "InternetExplorer.Application" )
objIEDebugWindow.Navigate "about:blank"
objIEDebugWindow.Visible = True
objIEDebugWindow.ToolBar = False
objIEDebugWindow.Width = 200
objIEDebugWindow.Height = 300
objIEDebugWindow.Left = 10
objIEDebugWindow.Top = 10
Do While objIEDebugWindow.Busy
WScript.Sleep 100
Loop
objIEDebugWindow.Document.Title = "IE Debug Window"
objIEDebugWindow.Document.Body.InnerHTML = _
"<b>" & Now & "</b></br>"
End If
objIEDebugWindow.Document.Body.InnerHTML = _
objIEDebugWindow.Document.Body.InnerHTML _
& myText & "<br>" & vbCrLf
End Sub
Function IsBlank(Value)
'returns True if Empty or NULL or Zero
If IsEmpty(Value) or IsNull(Value) Then
IsBlank = True
Exit Function
ElseIf VarType(Value) = vbString Then
If Value = "" Then
IsBlank = True
Exit Function
End If
ElseIf IsObject(Value) Then
If Value Is Nothing Then
IsBlank = True
Exit Function
End If
ElseIf IsNumeric(Value) Then
If Value = 0 Then
'wscript.echo " Zero value found"
IsBlank = True
Exit Function
End If
Else
IsBlank = False
End If
End Function
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both solutions worked thanks.
ASKER