Condividi tramite


Status MIF

The script generates a status MIF file using the Product, Version and Manufacturer as input parameters. The script calls the application and installs it, the exit code returned is captured either as success or failure. The mif file generated is placed under the temp folder

SCCM client agent looks in the temp folder to find a matching MIF file, if there is a match it reports the advertisement status based on this MIF file instead of the exit code returned by the application

Status MIF files help in scenarios where the applications return exit code other than 0 for success (for e.g. in our case exit code 1 was success)

Usage:

a. Copy the application you want to deploy to a folder

b. Copy the script below to the same folder

c. Also make sure you have the ismifcom.dll copied to the same folder. The script depends on the ismifcom.dll which you can copy from the SCCM SDK https://www.microsoft.com/downloads/details.aspx?FamilyId=064A995F-EF13-4200-81AD-E3AF6218EDCC&displaylang=en

Replace the following constants in the script to match the settings as per your application 

Example

Const Product = "Notepad"
Const Version = "1.0"
Const Manufacturer = "Microsoft"

ProductPackageName will automatically be taken as Notepad_1.0

Set oExecShell = WshShell.Exec ("Notepad.exe")

  'Dependency:
'SCCM SDK https://www.microsoft.com/downloads/details.aspx?FamilyId=064A995F-EF13-4200-81AD-E3AF6218EDCC&displaylang=en

 


  'Constants and Variables
Const cProductAction   = "Install"
Const Product    = "AppName"
Const Version    = "1.0"
Const Manufacturer   = "Microsoft"
ProductPackageName    = Product & "_" & Version
Set WshShell = CreateObject("WScript.Shell")
Dim InstallStatus

'init Objects
Set objShell = CreateObject ("WScript.Shell")
Set objEnv = objShell.Environment("Process")
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")

'Check client COM object and try to fix
If Not objFSO.FileExists(objEnv("WINDIR") & "\ismifcom.dll") then
Set objFileCopy = objFSO.GetFile(ScriptPath & "ismifcom.dll")
objFileCopy.Copy(objEnv("WINDIR") & "\ismifcom.dll")
exec = objShell.Run("regsvr32.exe /s Ismifcom.dll",0,TRUE)
End If

'init Mif Objects
Set objMIF = CreateObject("ISMIFCOM.InstallStatusMIF")

'Parameters
'============
'ProductPackageName : Unique name for the MIF file which by default will be AppName_1.0
'Manufacturer : Manufacturer or publisher of the product, for example, Microsoft.
'This parameter is limited to 64 characters.
'Product : Product or program name, for example, Product01. This parameter is
'limited to 64 characters.
'Version : Version of the product, for example, 1.0. This parameter is limited
'to 64 characters.
'Locale : Country/region or language code, for example, ENU. This parameter is
'optional and is limited to 16 characters.
'SerialNo : Serial number of the product. This parameter is optional and is
'limited to 64 characters.
'ExitMessage : Descriptive message about the status, added to the program status
'InstallStatus. This parameter is limited to 128 characters.
'Bsuccess: true if the install status is success. true|false.

'Create working directory for Wshshell
Set FileSys = CreateObject("Scripting.FileSystemObject")
'Set Current Working Directory to where script is running from
Dim CWD : CWD = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\"))
wshshell.currentdirectory = CWD

'Installing application
Install()

'Check install results
If InstallStatus = 1 Then
CheckExitCode InstallStatus, "Installation success. InstallStatus: " & InstallStatus, True
Else
CheckExitCode InstallStatus, "Installation failed. InstallStatus: " & InstallStatus, False
End If
wscript.sleep 5000
wscript.quit 0

'-------------------------------------------------------------
'Installing Application
'-------------------------------------------------------------
Sub Install()
Set oExecShell = WshShell.Exec ("setup.exe")
Do While oExecShell.Status = 0: WScript.Sleep 50: Loop
If oExecShell.ExitCode = 3010 Then
errReturn = 0
Else
errReturn = oExecShell.ExitCode
End If
InstallStatus = errReturn
End Sub

Sub CheckExitCode(ExitCode, ExitMessage, bSuccess)
if ExitCode = 0 then
objMif.Create ProductPackageName, Product, Manufacturer, Version, "ENU", " ", exitmessage, bsuccess
wscript.sleep 5000
wscript.quit (ExitCode)
Else
objMif.Create ProductPackageName, Product, Manufacturer, Version, "ENU", " ", exitmessage, bsuccess
 wscript.sleep 5000
 wscript.quit (ExitCode)
End If
End Sub

'Release objects
set objMIF = nothing
set objEnv = nothing
set objFSO = nothing

Comments

  • Anonymous
    November 22, 2013
    > objMif.Create ProductPackageName, Product, Manufacturer, Version, "ENU", " ", exitmessage, bsuccess The correct order of parameters is
  1. MIF FileName
  2. Manufacturer
  3. Product = Package Name Best regards