Usuário com melhor resposta
Verificar Versão e Service Pack do Microsoft Office

Pergunta
-
Bom dia galera!
Preciso verificar em todos os pcs da rede qual a versão do office instalada + service pack, alguem tem idéia de como faço isso?
Lembrando que preciso que gere um ÚNICO log onde contenha o nome da estação + versão office + SP
Até achei um script mas não funcionou, dá o seguinte erro
Algúem poderia verificar se o script está com algum erro? Não entendo de VB ou se algúem tiver outro script que faça a mesma coisa, me envie.
==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 2007
'
' NAME: PingSweep-OfficeVersion.vbs
'
' AUTHOR: DSCunningham
' DATE : 8/3/2011
'
' COMMENT:
' Sets up log file
' Builds IP range & sweeps range using for next Loop
' Gets computer name from IP for better logging
' Gets office (Outlook.exe) install path from registry
' Gets office (outlook.exe) version number and logs result
' I'm using Outlook.exe as the basis for determining the office version
' You could easily change it to check for winword.exe by changing the registry path and file name.
'==========================================================================
BaseIP = "192.168.1." 'Set this to match your IP subnet. Don't delete the period at the end.
StartIP = "1" 'Set this to the first IP in the range to scan
EndIP = "254" 'Set this to the last IP in the range to scan
Dim OfficeLog: OfficeLog = "OfficeLog.txt" 'Used to build office log. Will be created in path where script is run.
Const ForAppending = 8
Const HKEY_LOCAL_MACHINE = &H80000002 'Used for connecting to remote registry to find Outlook install path
Set objFSO = CreateObject("Scripting.FileSystemObject")
'=================================
'Setup log file
'=================================
'Checks for log file. If it doens't exist, it creates it.
'Created in whatever directory the script is run from.
If NOT objFSO.FileExists (OfficeLog) Then
Set checkLog = objFSO.CreateTextFile(OfficeLog)
checkLog.Close
End If
'Opens log for use
Set objLog = objFSO.OpenTextFile(OfficeLog, ForAppending)
'================================
'Build IP range. Currently only sweeps class C subnets.
'================================
'For loop to create IP address range
For i = StartIP To EndIP
IP = BaseIP & i
'================================
'Ping PC before checking for Office
'================================
'Checks the PC to see if it is accessible. Writes result to log.
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"& IP & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) Or objStatus.StatusCode<>0 Then
objLog.WriteLine (Date & vbTab & Time & vbTab & IP & vbTab & "No response")
WScript.Echo Date & vbTab & Time & vbTab & IP & vbTab & "No response"
ElseIf objStatus.StatusCode=0 Then
'****************
'This section captures the PC name and writes it to the log
' in addition to the IP address for more useful logging.
'****************
Set objWMIService = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
IP & "\root\cimv2")
Set colQry = objWMIService.ExecQuery("SELECT Name FROM Win32_ComputerSystem")
For Each Name In colQry
PCName = Name.name
'****************
'End PC name capture
'****************
objLog.WriteLine (Date & vbTab & Time & vbTab & IP & vbTab & PCName & vbTab & "PC responded to connection")
'****Comment out this "WSript.Echo" if running in WScript instead of CScript
WScript.Echo Date & vbTab & Time & vbTab & IP & vbTab & PCName & vbTab & "PC responded to connection"
'================================
'Check Registry to find install path of office
'================================
'Access remote registry and read a string (REG_SZ) value.
'Use to check registry for the install path of Outlook.exe
Dim strKeyPath 'everything after the main key IE: KHEY_LOCAL_MACHINE
Dim strValueName 'The name of the actual value within a key that you want to read
Dim strOutlookPath 'Output of path from registry
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & IP & "\root\default:StdRegProv")
'strKeyPath is everything after the main key IE: KHEY_LOCAL_MACHINE
strKeyPath = "Software\Microsoft\Windows\Currentversion\App Paths\OUTLOOK.EXE"
'strValueName is the name of the actual value within a key that you want to read
strValueName = "Path"
objReg.getStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strOutlookPath
'================================
'Get Office version
'================================
Set wshshell = CreateObject("WScript.Shell")
Select Case left(objFSO.GetFileVersion(strOutlookPath & "OUTLOOK.EXE"),2)
Case "9."
OfficeVersion = "Office 2000"
Case "10"
OfficeVersion = "Office XP"
Case "11"
OfficeVersion = "Office 2003"
Case "12"
OfficeVersion = "Office 2007"
Case "14"
OfficeVersion = "Office 2010"
End Select
objLog.WriteLine (Date & vbTab & Time & vbTab & IP & vbTab & PCName & vbTab & "Office version is " & OfficeVersion)
'****Comment out this "WSript.Echo" if running in WScript instead of CScript
WScript.Echo Date & vbTab & Time & vbTab & IP & vbTab & PCName & vbTab & "Office version is " & OfficeVersion
Next
End If
Next
Next
WScript.Echo "Script Complete"
Segue outro
Const forreading = 1
Const forwriting = 2
Set objfso = CreateObject("scripting.filesystemobject")
Set objlist = objfso.OpenTextFile("c:\list.txt", forreading) ' ** change list computer path
Set objreport = objfso.OpenTextFile("c:\report.txt", forwriting) ' ** change report file path
Do Until objlist.AtEndOfStream
sComputer = objlist.ReadLine
objreport.WriteLine sComputer
objreport.WriteLine "********"
If Reachable(sComputer) Then
iOfficeVer = GetOfficeVer(sComputer)
If iOfficeVer = -1 Then
objreport.WriteLine "Version of Office installed is unknown, " _
& "could not connect to the remote computer." & vbcrlf
ElseIf iOfficeVer = 0 Then
objreport.WriteLine "Office is not installed." & vbcrlf
Else
objreport.WriteLine "Version of Office installed: " & iOfficeVer & vbcrlf
End If
Else
objreport.WriteLine "Computer is Unreachable!" & vbcrlf
End If
Loop
Function GetOfficeVer(sNode)
On Error Resume Next
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& sNode & "/root/default:StdRegProv")
If Err.Number <> 0 Then
GetOfficeVer = -1
Exit Function '------->
End If
sValueName = "Path"
sRegPre = "SOFTWARE\Microsoft\Office\"
sRegPost = "\Common\InstallRoot"
If oReg.GetStringValue( _
HKLM, sRegPre & "12.0" & sRegPost, sValueName, sValue ) = 0 Then
GetOfficeVer = 2007
ElseIf oReg.GetStringValue( _
HKLM, sRegPre & "11.0" & sRegPost, sValueName, sValue) = 0 Then
GetOfficeVer = 2003
ElseIf oReg.GetStringValue( _
HKLM, sRegPre & "10.0" & sRegPost, sValueName, sValue) = 0 Then
GetOfficeVer = 2002
ElseIf oReg.GetStringValue( _
HKLM, sRegPre & "9.0" & sRegPost, sValueName, sValue) = 0 Then
GetOfficeVer = 2000
ElseIf oReg.GetStringValue( _
HKLM, sRegPre & "8.0" & sRegPost, sValueName, sValue) = 0 Then
GetOfficeVer = 97
Else
GetOfficeVer = 0
End If
End Function
Function Reachable(strComputer)
' On Error Resume Next
Dim objShell, objExec, strCmd, strTemp
strCmd = "ping -n 1 " & strComputer
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec(strCmd)
strTemp = UCase(objExec.StdOut.ReadAll)
If InStr(strTemp, "REPLY FROM") Then
Reachable = True
Else
Reachable = False
End If
End Functionrbo
- Editado RBANDEIRA terça-feira, 27 de agosto de 2013 14:28
Respostas
-
Não parece ser problema do script. Como vc disse ele funcionou em certa faixa.
Já verificou Firewall da máquinas onde não funciona?
Já tentou rodar o script de dentro da máquina que deu problema?
Ou você não tentou fazer troubleshooting ou está faltando informação do problema.
Fábio de Paula Junior
- Marcado como Resposta Alysson QueirozModerator segunda-feira, 30 de setembro de 2013 20:29
Todas as Respostas
-
RBandeira,
Se o erro que você postou é referente ao primeiro script deve ser porque a primeira linha não está comentada, veja que o erro já indica a linha onde está o erro (Linha 1).
Aparentemente sua linha 1 é uma sequencia de "=", você tem que apagar esta linha ou comentá-la(colocar o apóstrofo), assim:
'========================================================================== ' ' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 2007 ' ' NAME: PingSweep-OfficeVersion.vbs
Tente executar novamente.
Fábio de Paula Junior
-
-
-
-
-
Não parece ser problema do script. Como vc disse ele funcionou em certa faixa.
Já verificou Firewall da máquinas onde não funciona?
Já tentou rodar o script de dentro da máquina que deu problema?
Ou você não tentou fazer troubleshooting ou está faltando informação do problema.
Fábio de Paula Junior
- Marcado como Resposta Alysson QueirozModerator segunda-feira, 30 de setembro de 2013 20:29