Code:
set WshShell = createObject ("WScript.Shell")
set fso = CreateObject("Scripting.FileSystemObject")
set oReg = getObject("Winmgmts:root\default:StdRegProv")
set ShellApp = createObject("Shell.Application")Source_dir = WScript.ScriptFullName
Source_dir = left(Source_dir, inStrRev(Source_dir, "\"))
const ForReading = 1
const ForWriting = 2
' Allgemeine Definitionen
Version_GA = "ST_R18GA"
Version_SP = "ST_R18SP5"
Version_HF = "NONE"
V5_ident = "B18"
ST_ident = "Smarteam"
Oracle_C = "OracleDir_C"
Oracle_D = "OracleDir_D"
Smarteam_C = "ST_Dir_C"
Smarteam_D = "ST_Dir_D"
ST_Server = "ServerName"
Root_dir = "D:\Dassault Systemes\"
ST_Install_dir = Root_dir & ST_ident
V5_Install_dir = Root_dir & V5_ident
Oracle_Install_dir_D = "D:\"
OracleClientBin = "D:\oracle\product\10.2.0\client_1\bin"
ViewerMsiFile = Source_dir & "\SMARTEAM_Viewer_190200\SMARTEAM - Viewer.msi"
SP_MspFile = Source_dir & Version_SP & "\Kits\SMARTEAM - Editor\SMARTEAM - Editor V5R18 SP5.msp"
ISMsiFile = Source_dir & Version_GA & "\SMARTEAM\ISScript1150.msi"
EdMsiFile = Source_dir & Version_GA & "\SMARTEAM\SmarTeam - Editor.msi"
tmppath = "C:\Temp"
if not fso.FolderExists(tmppath) then set fo = fso.CreateFolder(tmppath)
LogFileName = tmppath & "\" & left(Version_GA, 6) & "_install.log"
set LogFile = fso.OpenTextFile(LogFileName, ForWriting, True)
Space_needed_C = 300 ' Define in MByte
Space_needed_D = 800 ' Define in MByte
set objEnvP = WshShell.Environment("Process")
ComputerName = objEnvP("COMPUTERNAME")
Sysroot = objEnvP("Systemroot")
WinDir = objEnvP("windir")
ProgramFilesDir = objEnvP("ProgramFiles") & "\"
FrameworkVersion = "Framework"
OS_Source = "INTEL"
OS_Target = "intel_a"
Tools_Target = "Tools"
LogFile.WriteLine Date() & " " & time() & vbCrLf
LogFile.WriteLine ComputerName & vbCrLf
LogFile.WriteLine "V5_ident = " & V5_ident & vbCrLf
LogFile.WriteLine "ST_ident = " & ST_ident & vbCrLf
LogFile.WriteLine "Version_GA = " & Version_GA & vbCrLf
LogFile.WriteLine "Version_SP = " & Version_SP & vbCrLf
LogFile.WriteLine "Version_HF = " & Version_HF & vbCrLf
LogFile.WriteLine "TMP = " & objEnvP("TMP") & vbCrLf
LogFile.WriteLine "TEMP = " & objEnvP("TEMP") & vbCrLf
LogFile.WriteLine "Source_dir = " & Source_dir & vbCrLf
' Löschen alte Versionen
Installation = True ' Flag für Aufruf aus der Installationsprozedur
Call Include (Source_dir & "Uninstall_Smarteam.vbs")
if ST_server = "" then
LogFile.WriteLine "ErrorStatus = 1200" & vbCrLf
LogFile.WriteLine "Smarteam server not defined !! ------- Stopping installation. ------ Please contact your system administrator." & vbCrLf
LogFile.Close
Call LogFile_Check(LogFileName)
wscript.quit (1200)
end if
' Check if V5 is installed
if not fso.FileExists(V5_Install_dir & "\OSNT") then
LogFile.WriteLine "ErrorStatus = 1320" & vbCrLf
LogFile.WriteLine "CATIA V5 is not installed !! ------ Install V5 first ------ Please contact your system administrator." & vbCrLf
LogFile.Close
Call LogFile_Check(LogFileName)
wscript.quit (1320)
Else
LogFile.WriteLine "Catia V5 " & V5_Ident & " directory exists" & vbCrLf
end if
' Check ob Source Directory existiert
if not fso.FolderExists(Source_dir & Version_GA) then
LogFile.WriteLine "ErrorStatus = 1300" & vbCrLf
LogFile.WriteLine "Smarteam Source directory for " & Version_GA & " is missing !! ------ Please contact your system administrator." & vbCrLf
LogFile.Close
Call LogFile_Check(LogFileName)
wscript.quit (1300)
end if
' Check partition and disk space
set dr = fso.Getdrive("C")
if Space_needed_C > int(dr.FreeSpace / 1024 / 1024) then
LogFile.WriteLine "ErrorStatus = 1310" & vbCrLf
LogFile.WriteLine "Not enough space on harddisk C: !! -------- Minimum needed: " & Space_needed & " MBytes ------- Stopping installation. -------- Please contact your system administrator." & vbCrLf
LogFile.WriteLine "Available: " & (dr.FreeSpace /1024 /1024) & " MBytes" & vbCrLf
LogFile.Close
Call LogFile_Check(LogFileName)
wscript.quit (1310)
end if
if not fso.DriveExists("D") then
LogFile.WriteLine "ErrorStatus = 1315" & vbCrLf
LogFile.WriteLine "Drive D does not exist !! ------- Stopping installation. -------- Please contact your system administrator." & vbCrLf
LogFile.Close
Call LogFile_Check(LogFileName)
wscript.quit (1315)
End If
set dr = fso.Getdrive("D")
if Space_needed_D > int(dr.FreeSpace / 1024 / 1024) then
LogFile.WriteLine "ErrorStatus = 1317" & vbCrLf
LogFile.WriteLine "Not enough space on harddisk D: !! -------- Minimum needed: " & Space_needed & " MBytes ------- Stopping installation. -------- Please contact your system administrator." & vbCrLf
LogFile.WriteLine "Available: " & (dr.FreeSpace /1024 /1024) & " MBytes" & vbCrLf
LogFile.Close
Call LogFile_Check(LogFileName)
wscript.quit (1317)
end if
' Check if .NET Framework 2.0 is installed and define security for .NET applications
if not fso.FolderExists(Sysroot & "\Microsoft.NET\" & FrameworkVersion & "\v2.0.50727") then
LogFile.WriteLine "ErrorStatus = 2500" & vbCrLf
LogFile.WriteLine ".NET 2.0 not installed ------ Install .NET 2.0 first ------ Please contact your system administrator." & vbCrLf
wscript.quit (2500)
else
LogFile.WriteLine ".NET Framework 2.0 SP1 installed " & vbCrLf
End If
' Installation Oracle Client
if not fso.FolderExists(Source_dir & Oracle_C) then
LogFile.WriteLine "Info: Oracle_C directory is missing !! -------- Not copied --------- Please contact your system administrator." & vbCrLf
LogFile.Close
Call LogFile_Check(LogFileName)
wscript.quit (1330)
else
fso.CopyFolder Source_dir & Oracle_C & "\*", ProgramFilesDir
LogFile.WriteLine "Oracle C Directory copied" & vbCrLf
End if
if not fso.FolderExists(Source_dir & Oracle_D) then
LogFile.WriteLine "Info: Oracle_D directory is missing !! -------- Not copied --------- Please contact your system administrator." & vbCrLf
LogFile.Close
Call LogFile_Check(LogFileName)
wscript.quit (1340)
else
fso.CopyFolder Source_dir & Oracle_D & "\*", Oracle_Install_dir_D
LogFile.WriteLine "Oracle D Directory copied" & vbCrLf
End if
set objEnv = WshShell.Environment("System")
PFAD = objEnv("PATH")
If InStr(1, Pfad, OracleClientBin) = 0 Then
objEnv("PATH") = PFAD & ";" & OracleClientBin
LogFile.WriteLine "PATH Variable modified (system)" & vbCrLf
LogFile.WriteLine objEnv("PATH") & vbCrLf
Else
LogFile.WriteLine "PATH Variable already defined" & vbCrLf
End If
command = "Regedit.exe /s " & Source_dir & "Oracle.reg"
LogFile.WriteLine command & vbCrLf
WshShell.Run Command, 4,true
' Registration of the Server dll's for specific extension
set objEnv = WshShell.Environment("Process")
PFAD = objEnv("PATH")
objEnv("PATH") = PFAD & ";" & OracleClientBin
LogFile.WriteLine "PATH Variable modified (process)" & vbCrLf
LogFile.WriteLine objEnv("PATH") & vbCrLf
command = "regsvr32.exe /s " & OracleClientBin & "\OraOLEDB10.dll"
LogFile.WriteLine command & vbCrLf
WshShell.Run Command, 4,true
' Installing Smarteam Editor
LogMsi = tmppath & "\Smarteam_msi.log"
command = "msiexec /i """ & ISMsiFile & """ /qb! /lemo+ """ & LogMsi & """"
LogFile.WriteLine command & vbCrLf
WshShell.Run Command, 4,true
command = "msiexec /i """ & EdMsiFile & """ /qb! /lemo+ """ & LogMsi & """ USERNAME=Admin COMPANYNAME=""FIRMA"" ALLUSERS=1 MAIN_INSTALLATION_TYPE=Client SUB_INSTALLATION_TYPE=Custom SM_LUM_LOCAL_NETWORK=Network SM_LUM_SERVER_LOCATION=lumserver SM_SETUP_LANGUAGE=German SM_CORE_SERVICES_SERVER=""" & ST_Server & """ ADDLOCAL=SmarTeam_ClientLibrary,SmarTeamCore,SmarTeam_SDK,SmarTeam,SmarTeam_Tools,Users_Maintenance,SmartFlow_Tools,SmarTeam_Plugins,CATIA_Integration,MS_Excel_Integration,MS_Word_ Integration,SmarTeam_BOM,Online_BOM,Offline_BOM,Viewers,eDrawings_Viewer,IE_Viewer,ENOVIA_Viewer,SmarTeam_Help,SmartFlow_Help,SmarTeam_Works_Help,MsOffice_Integration_Help,Icons_Li brary INSTALLDIR=""" & ST_Install_dir & """"
LogFile.WriteLine command & vbCrLf
WshShell.Run Command, 4,true
' Installing Smarteam SP
if Version_SP <> "NONE" then
command = "msiexec /p """ & SP_MspFile & """ /qb! REINSTALL=ALL V5R18=YES /lemo+* """ & LogMsi & """"
LogFile.WriteLine command & vbCrLf
WshShell.Run Command, 4,true
Else
LogFile.WriteLine "Info: SP installation not defined !!" & vbCrLf
End If
' Installing SMARTEAM HF
if Version_HF <> "NONE" then
' not yet defined
Else
LogFile.WriteLine "Info: Hotfix installation not defined !!" & vbCrLf
end if
' Installing SMARTEAM Viewer
command = "msiexec /i """ & viewerMsiFile & """ /qb! /lemo+ """ & LogMsi & """"
LogFile.WriteLine command & vbCrLf
WshShell.Run Command, 4,true
' Copy of the Smarteam specific files and directories
fso.CopyFolder Source_dir & Smarteam_C & "\*", ProgramFilesDir
LogFile.WriteLine "Smarteam C Directory copied" & vbCrLf
fso.CopyFolder Source_dir & Smarteam_D & "\*", ST_Install_dir
LogFile.WriteLine "Smarteam D Directory copied" & vbCrLf
command = "regsvr32.exe /s " & ST_Install_dir & "\Script\msflxgrd.ocx"
LogFile.WriteLine command & vbCrLf
WshShell.Run Command, 4,true
command = "regsvr32.exe /s " & ST_Install_dir & "\Script\pdmAR.dll"
LogFile.WriteLine command & vbCrLf
WshShell.Run Command, 4,true
command = "regsvr32.exe /s " & ST_Install_dir & "\Script\pdmLib.dll"
LogFile.WriteLine command & vbCrLf
WshShell.Run Command, 4,true
command = "regsvr32.exe /s " & ST_Install_dir & "\Script\pdmUtils.dll"
LogFile.WriteLine command & vbCrLf
WshShell.Run Command, 4,true
' Finish installation
LogFile.WriteLine Date() & " " & time() & vbCrLf
LogFile.WriteLine "Installation finished" & vbCrLf
LogFile.Close
' Check Log File and Mail it if there is a problems
Call LogFile_Check(LogFileName)
wscript.quit (0)
'========================================================================================================================
Sub LogFile_Check(LogFileName)
set objEnvP = WshShell.Environment("Process")
ComputerName = objEnvP("COMPUTERNAME")
set LogFile = fso.OpenTextFile(LogFileName, ForReading)
strText = LogFile.ReadAll
LogFile.Close
Const Server = "smtp.abc.com"
Set objEmail = CreateObject("CDO.Message")
Maillist = "mail@abc.de"
objEmail.From = "Smarteam.installation@" & Computername & ".ch"
objEmail.To = Maillist
If InStr(strText, "Please contact your system administrator") Then
objEmail.Subject = "Smarteam Installation Problem (" & ComputerName & ")"
Else
objEmail.Subject = "Smarteam Installation OK (" & ComputerName & ")"
End If
objEmail.Textbody = strText
If fso.FileExists(objEnvP("TMP") & "\cxinst.log ") Then
attachment = objEnvP("TMP") & "\cxinst.log "
Elseif fso.FileExists(objEnvP("TEMP") & "\cxinst.log ") Then
attachment = objEnvP("TEMP") & "\cxinst.log "
elseif fso.FileExists("C:\cxinst.log ") Then
attachment = "C:\cxinst.log "
else
attachment = ""
End If
if attachment <> "" then
objEmail.AddAttachment attachment
End If
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = Server
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
if fso.FileExists(attachment) Then fso.DeleteFile(attachment)
End Sub
'========================================================================================================================
Sub Include(cNameScript)
dim oFS
dim oFile
set oFS = createObject("Scripting.Filesystemobject")
set oFile = oFS.OpenTextFile( cNameScript )
ExecuteGlobal oFile.ReadAll()
oFile.Close
end sub
' End