Principales respuestas
como puedo automatizar un escript para que realice actualizaciones q tengo en una usb?

Pregunta
-
tengo el siguiente escript pero no ejecuta la actualizacion en que estoy fallando?
' Constant block
Const cComputer = "."
Const ForReading =1, ForWriting=2, ForAppending=3' Microsoft Online Services Sign-In Assistant (IDCRL7) -
Const c_x86_signin = "\\C:\msoidcrl.msi"
Const c_x64_signin = "\\C:\Deploy SignIn Assistant O365\ClienteO365\x64\msoidcrl.msi"' Get the temporary folder
Set wshShell = CreateObject( "WScript.Shell" )
sTemp = wshShell.ExpandEnvironmentStrings( "%TEMP%" )
Set wshShell = Nothing' Define the logfilename based on the current date
sLogFile = sTemp & "\O365_" & GetDateTimeFilename() & "_InstallClient.log"' Open output file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile(sLogFile, ForWriting, True)objLogFile.WriteLine "-------------------------------------------------------------------------------------------"
objLogFile.WriteLine "BPOS_Desktops_InstallUpdates"
objLogFile.WriteLine "Started: " & Now()
objLogFile.WriteLine "Logfile: " & sLogFile
objLogFile.WriteLine "-------------------------------------------------------------------------------------------"gLog "Start of the detection process..."
sArch = DetectArchitecture
gLog "Processor Architecture: " & sArch
gLog "Detection process finished."gLog "We need to install updates for [" & sArch & "]"
' First we will process x86 updates
If (sArch = "X86") Then
'Install c_x86_signin
gLog "Installing the " & c_x86_signin & " update."
sMsg = InstallMSI_7(c_x86_signin)
gLog "Message returned from the Windows Installer: " & sMsg
Else
'Install c_x64_signin
gLog "Installing the " & c_x64_signin & " update."
sMsg = InstallMSI_7(c_x64_signin)
gLog "Message returned from the Windows Installer: " & sMsg
End If
gLog "End of script execution."
Function RegKeyExists(sComputerName, sRegKey)
Dim oReg, aValueNames, aValueTypes
sRegKey = Trim(sRegKey)
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputerName & "\root\default:StdRegProv")
If oReg.EnumValues(HKCU, sRegKey, aValueNames, aValueTypes) = 0 Then
RegKeyExists = True
Else
RegKeyExists = False
End If
Set oReg = Nothing
End FunctionSub RegValueSet (Byval sComputerName, Byval sKey, Byval sRegValue, Byval sRegValueData)
Dim oRegSet oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputerName & "\root\default:StdRegProv")
If Not RegKeyExists(sComputerName, sKey) Then
oReg.CreateKey HKCU, sKey
End IfoReg.SetDwordValue HKCU, sKey, sRegValue, sRegValueData
Set oReg = Nothing
End SubSub RegValueDelete (Byval sComputerName, Byval sKey, Byval sRegValue)
Dim oRegSet oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputerName & "\root\default:StdRegProv")
If RegValueExists(sComputerName, sKey, sRegValue) Then
oReg.DeleteValue HKCU, sKey, sRegValue
End If
Set oReg = Nothing
End SubFunction RegValueExists(Byval sComputerName, Byval sRegKey, Byval sRegValue)
Dim aValueNames, aValueTypes, oReg, i
sRegKey = Trim(sRegKey)
sRegValue = LCase(Trim(sRegValue))
RegValueExists = False
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputerName & "\root\default:StdRegProv")
If oReg.EnumValues(HKCU, sRegKey, aValueNames, aValueTypes) = 0 Then
If Not IsNull(aValueNames) Then
For i = 0 To UBound(aValueNames)
If LCase(aValueNames(i)) = sRegValue Then
RegValueExists = True
End If
Next
End If
End If
Set oReg = Nothing
End Function'---
' Function to define a filename based on the current date and time
'---
Function GetDateTimeFilenameaDay = Right("0" & Day(Date), 2)
aMonth = Right("0" & Month(Date), 2)
aYear = Year(Date)
aTime = Now
aHour = Right("0" & Hour(aTime), 2)
aMin = Right("0" & Minute(aTime), 2)GetDateTimeFilename = CStr(aYear) + "-" + CStr(aMonth) + "-" + CStr(aDay) + "-" + CStr(aHour) + CStr(aMin)
End Function
Sub gLog(sMsg)
objLogFile.WriteLine "[" & Now() & "] " & sMsg
End Sub'---
' Function to detect the processor architecture
'---
Function DetectArchitectureSet wshShell = CreateObject( "WScript.Shell" )
sReturn = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
Set wshShell = Nothing
'WScript.Echo sReturnDetectArchitecture = UCase(sReturn)
End Function'---
' Function to Install MSI packages
'---
Function InstallMSI(PATHTOMSI)Dim installer
'Err.Clear()
'On Error Resume Next
Set installer = Wscript.CreateObject("WindowsInstaller.Installer")
'installer.uilevel = 2
installer.InstallProduct PATHTOMSI
Set installer = Nothing
On Error Goto 0InstallMSI = Err.Number & " " & Err.Description
End Function
'---
' Function to Install EXE packages
'---
Function InstallEXE(PATHTOEXE)Dim oShell, sReturn
'Err.Clear()
On Error Resume Next
Set oShell = CreateObject("WScript.Shell")
sReturn = 0
sReturn = oShell.Run(PATHTOEXE, 1 ,True)
Set oShell = Nothing
On Error Goto 0
InstallEXE = sReturn & " " & Err.Number & " " & Err.Description
End Function'---
' Function to Install EXE packages
'---
Function InstallMSI_7(PATHTOMSI)Dim oShell, sReturn
'Err.Clear()
'On Error Resume Next
Set oShell = CreateObject("WScript.Shell")
sReturn = 0
sReturn = oShell.Run("%COMSPEC% /c msiexec /i" & PATHTOMSI & "quiet, 2 ,True")
Set oShell = Nothing
On Error Goto 0
InstallMSI_7 = sReturn & " " & Err.Number & " " & Err.Description
End Functionno funciona alguien sabe por que?
jueves, 9 de agosto de 2012 22:31
Respuestas
-
Hola danykas, prueba en el sigueitne foro para recibir mas ayuda:
http://social.technet.microsoft.com/Forums/es-ES/category/scripting
Microsoft MVP Windows Expert - Consumer
- Marcado como respuesta LeoPontiMicrosoft employee, Moderator sábado, 11 de agosto de 2012 16:44
sábado, 11 de agosto de 2012 14:02