OMPM 的示例 SMS 部署脚本
更新时间: 2009年1月
应用到: Office Resource Kit
上一次修改主题: 2009-01-13
可以使用与从中心文件共享调用这些文件的以下内容类似的脚本。您可以使用 SMS 部署脚本。
'*************************************************************************************
' File Name: OffScan.vbs
' Version: 1.0
' Purpose: Executes offscan.exe and generate the MIF message based on output of offscan.exe
'*************************************************************************************
Option Explicit
''On Error Resume Next
Dim oFso, oWsh, g_strRoot, g_SourcePath, g_optFile, g_intReturnCode
'------------------- Creating Objects -------------------------------
Set oFso = Wscript.CreateObject("Scripting.FileSystemObject")
Set oWsh = Wscript.CreateObject("Wscript.Shell")
'------------- Get the Parent Folder -------------------------------
g_strRoot = oFso.GetParentFolderName(Wscript.ScriptFullName)
g_optFile = oWsh.ExpandEnvironmentStrings("%temp%\offscan_output.txt")
g_SourcePath = oFso.BuildPath(g_strRoot,"bits\offscan.exe")
If oFso.FileExists(g_optFile) Then
oFso.DeleteFile g_optFile
End If
g_intReturnCode= oWsh.Run("%comspec% /c " & g_SourcePath & " >> " & g_optFile,0,True)
'// Remove this if network copy is not requried
CopycabfiletoNetworkLocation
Quit()
'****************************************************************************************************************
'Sub Name : GenerateMIFMessage()
'Purpose: Generates the MIF message
'****************************************************************************************************************
Sub GenerateMIFMessage()
'On Error Resume Next
Dim l_varGetFile,l_strReadFile,l_strLine, l_oMIFGen, l_strMifMessage
If oFso.FileExists(g_optFile) Then
Set l_varGetFile = oFso.GetFile(g_optFile)
Set l_strReadFile = l_varGetFile.OpenAsTextStream(1,-2)
Do While l_strReadFile.AtEndofStream = False
l_strLine = l_strReadFile.ReadLine
If Not Trim(l_strLine) = "" Then
If Instr(lcase(l_strLine),"total time") or Instr(lcase(l_strLine),"total number") Then
If Trim(l_strMifMessage) = "" Then
l_strMifMessage = g_intReturnCode & ":" & l_strLine
Else
l_strMifMessage = l_strMifMessage & ";" & l_strLine
End If
End If
If Instr(lcase(l_strLine),"error:") Then
If Trim(l_strMifMessage) = "" Then
l_strMifMessage = g_intReturnCode & ":" & Split(Split(l_strLine,".")(0),":")(1)
Else
l_strMifMessage = l_strMifMessage & ";" & Split(Split(l_strLine,".")(0),":")(1)
End If
End If
End If
Loop
Set l_strReadFile = Nothing
Set l_varGetFile = Nothing
Else
l_strMifMessage="Output file NOT found"
End If
Set l_oMIFGen = WScript.CreateObject("ISMIFCOM.InstallStatusMIF")
l_oMIFGen.Create "OffScan.MIF", "Microsoft", "Office File Scanner", "1.0", "ENU", 1, l_strMifMessage, 1
End Sub
'*************************************************************************************
' Sub Name: Quit
' Purpose: Exit
'*************************************************************************************
Sub Quit()
'On Error Resume Next
GenerateMIFMessage()
Set oWsh = Nothing
Set oFso = Nothing
Wscript.Quit(0)
End Sub
'*************************************************************************************
'Sub Name : CopycabfiletoNetworkLocation()
'Purpose: Copy the cab file to specified common folder
'*************************************************************************************
Sub CopycabfiletoNetworkLocation()
'On Error Resume Next
Dim l_strDemoFolder, l_strFile, l_oFileCollection
Dim l_offSacnIniPath, l_SourceFolder, l_destinationFolder
l_offSacnIniPath="bits\offscan.ini"
l_SourceFolder="%temp%\offscan" '%temp%\offscan - this shold be same as in offscan.ini file.
'//--------------- Specify the Share name (share name should end with "\" )--------------------
l_destinationFolder= "\\server\sharename\"
l_offSacnIniPath = oFso.BuildPath(g_strRoot,l_offSacnIniPath)
If oFso.FileExists(l_offSacnIniPath) Then
l_SourceFolder = oWsh.ExpandEnvironmentStrings(l_SourceFolder)
Set l_strDemoFolder = oFso.GetFolder(l_SourceFolder)
Set l_oFileCollection = l_strDemoFolder.Files
For Each l_strFile in l_oFileCollection
oFso.CopyFile l_strFile,l_destinationFolder
Next
Set l_oFileCollection = Nothing
Set l_strDemoFolder = Nothing
End If
If oFso.FileExists(g_optFile) Then
oFso.CopyFile g_optFile,l_destinationFolder
End If
End Sub
下载此书籍
本主题包含在以下可下载书籍内,以方便您阅读和打印:
2007 Office 版本的技术参考(该链接可能指向英文页面)
有关可下载书籍的完整列表,请参阅 2007 Office Resource Kit 的可下载书籍。