Two files are needed to do this.
Here is the KiX script:
AdminScriptEditor Script Conversion
http://www.kixtart.org/udf
If Not @LOGONMODE
Break On
Else
Break Off
EndIf
Dim $RC
$RC = SetOption("Explicit", "On")
$RC = SetOption("NoMacrosInStrings", "On")
$RC = SetOption("NoVarsInStrings", "On")
If @SCRIPTEXE = "KIX32.EXE"
$RC = SetOption("WrapAtEOL", "On")
EndIf
Dim $strIPAddress, $intI
Dim $strNetworkID, $strMask
Dim $strUninstallRegPath, $strUninstallRegKey
Dim $strServer, $strPath, $strFile, $strSwitches
Dim $strDisplayVersion
If Not IsDeclared($INI)
Exit 87
EndIf
If Not IsDeclared($Section)
Exit 87
EndIf
$intI = 0
$strNetworkID = Split(ReadProfileString($INI, $Section, "NetworkID"), ";")
$strUninstallRegPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
$strUninstallRegKey = ReadProfileString($INI, $Section, "UninstallRegKey")
$strServer = ReadProfileString($INI, $Section, "Server")
$strPath = ReadProfileString($INI, $Section, "Path")
$strFile = ReadProfileString($INI, $Section, "File")
$strSwitches = ReadProfileString($INI, $Section, "Switches")
$strDisplayVersion = ReadProfileString($INI, $Section, "DisplayVersion")
$strIPAddress = EnumIPInfo($intI, 0, 1)
While Not @ERROR
If IsInSubnet($strIPAddress, $strNetworkID, , 1)
If Not KeyExist($strUninstallRegPath + $strUninstallRegKey) = 1
fnInstallSoftware($strServer, $strPath, $strFile, $strSwitches)
Exit @ERROR
Else
If CompareVersions($strDisplayVersion, ReadValue($strUninstallRegPath + $strUninstallRegKey, "Displayversion")) = 1
fnInstallSoftware($strServer, $strPath, $strFile, $strSwitches)
Exit @ERROR
Else
Exit @ERROR
EndIf
EndIf
EndIf
$intI = $intI + 1
$strIPAddress = EnumIPInfo($intI, 0, 1)
Loop
Exit @ERROR
Function fnInstallSoftware($strServer, $strPath, $strFile, $strSwitches)
Dim $RC
$RC = WMIPing($strServer)
If Not @ERROR
If Exist("\\" + $strServer + $strPath + $strFile)
Shell "\\" + $strServer + $strPath + $strFile + " " + $strSwitches
EndIf
EndIf
Exit @ERROR
EndFunction
Here is the INI file:
AdminScriptEditor Script Conversion
[K-Lite Codec Pack Full]
NetworkID=192.168.1.0/24;172.16.0.0/16
UninstallRegKey=KLiteCodecPack_is1
DisplayVersion=3.25
Server=Server
Path=\Packages$\Codecs\K-Lite\Full\
File=klcodec325f.exe
Switches=/verysilent /norestart /LoadInf=".\klcpf.ini" /MERGETASKS="fa_mpc\qt, fa_mpc\real, speaker\20"