今天分享的脚本,实际上针对批量卸载Office 2003和安装Open Office结果的确认,脚本只返回软件名称中包含有“office”和“Java”的软件名称(去除这个限制,即可返回所有已安装的软件列表。
如果你的企业中安装了资产管理软件就另当别论了(如果您想使用开源的资产管理产品,可以去体验一下OCS和GLPI,有类似于OTRS的功能)。
- '*************************************************
- ' Script : Check MS Office & OpenOffice
- ' Last Modified : 2010-08-03
- ' Version : 1.0
- '*************************************************
- On Error Resume Next
- Const HKLM = &H80000002
- Const strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall\"
- Const ForReading = 1
- Const ForAppending = 8
- Set Wshell = CreateObject("Wscript.Shell")
- Set objFSO = CreateObject("Scripting.FileSystemobject")
- Set objFile = objFSO.OpenTextFile("c:\AllPC.txt")
- Set textWriteFile = objFSO.OpenTextFile("c:\CheckLog.txt",ForAppending,True)
- Do
- strComputer =objFile.ReadLine
- Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
- objReg.EnumKey HKLM, strKeyPath,arrSubKeys
- For Each strSubKey In arrSubKeys
- intRet = objReg.GetStringValue(HKLM, strKeyPath & strSubKey,"DisplayName",strValue)
- If strValue <> "" And intRet = 0 And inStr(1,strValue,"Office",1) >0 Then
- WScript.Echo strComputer & " " & strValue
- textWriteFile.WriteLine(strComputer & " " & strValue)
- End If
- If strValue <> "" And intRet = 0 And inStr(1,strValue,"Java",1) >0 Then
- WScript.Echo strComputer & " " & strValue
- textWriteFile.WriteLine(strComputer & " " & strValue)
- End If
- Next
- Loop Until objFile.AtEndOfStream
- textWriteFile.Close
- objFile.Close
其中
c:\AllPC.txt 为目标计算机列表,以便实现批量的检查,而
c:\CheckLog.txt
则为脚本执行后输出的日志。
使用方法:请使用具有本地管理员权限的用户以Cscript(默认情况下为Wscript方式)方式运行。