Compartir a través de


Script de implementación de SMS de ejemplo para OMPM

Actualizado: enero de 2009

Se aplica a: Office Resource Kit

 

Última modificación del tema: 2009-01-13

Puede usar un script similar al siguiente que llame estos archivos desde el recurso compartido de archivos central. Puede implementar el script con 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

Descargar este libro

En este tema se incluye el siguiente libro descargable para facilitar la lectura y la impresión: