Two files are needed to do this.
  • A KiX script
  • An INI file

Here is the KiX script:




AdminScriptEditor Script Conversion




;*************************************************************************
;
SCRIPT NAME GPO-Machine-StartupScript-Installations.kix
;
;
ACTION Install software during GPO Computer Startup Script
;

;
AUTHOR Wim Rotty
;
;
CONTRIBUTORS
;
;
VERSION 1.0.0.0
;

;
DATE CREATED 2007-07-13
;

;
DATE MODIFIED
;

;
KIXTART
;

;
USAGE Copy KIX32.EXE, WKIX32.EXE, the script and the INI file to the share
;
\\domain-name\SysVol\domain-name\scripts\
;
Create a Computer Startup Script Group Policy
;
As "Script Name", use
;
\\domain-name\SysVol\domain-name\scripts\WKIX32.EXE
;
As "Script Parameters", use
;
\\domain-name\SysVol\domain-name\scripts\script.kix $INI="\\domain-name\SysVol\domain-name\scripts\script.ini" $Section="Package Name"
;
Create a Global Security Group, add the computers where the software has to be installed
;
Change the Security Property for the Group Policy
;
Remove "Read" and "Apply Group Policy" Security rights for "Authenticated Users"
;
Add the Global Security Group
;
Give "Read" and "Apply Group Policy" Security rights
;
Copy the install Package on a share on your installation server
;
Change the NTFS Security on the share and eventually the share permissions
;
Grant "Full Control" permissions to the "Domain Admins" group
;
Grant "Read" permissions to the "Domain Computers" group
;
;
PARAMETERS $INI
;
Required
;
Filename of initialization file with set of parameters, eventually preceeded by the path
;
;
$Section
;
Required
;
Name of section that contains information of software that has to be installed
;

;
RETURNS Errorcode
;

;
REMARKS
;
;
DEPENDENCIES User Defined Functions to be found on http://www.kixtart.org/udf
;
- IsInSubnet()
;
- WMIPing()
;
- CompareVersions()
;

;
EXAMPLE
;

;
DESCRIPTION Software is only installed if certain conditions are fullfilled
;
- The software installation is launched with an executable ending with ".exe"
;
- A silent installation must be possible
;
- The computer has to be in one or more defined networks
;
otherwise the software is not installed
;
- The software to be installed has to create an UNINSTALL registry key under
;
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
;
- Under this key, the DisplayVersion data is required
;
- If the Uninstall registry key does not exist, the software is installed
;
- If the Uninstall key exists, but the Value for DisplayVersion is older
;
than the package being deployed, the software is installed
;
- upgrades must use the same Uninstall key as the installed version
;
;
*************************************************************************

;Script Options
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

;Declare vaiables
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

;Initialize variables
$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")

;Code
$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

;Personal UDF section, these UDF's are made just for this script

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

;UDF section
;
...
;
Add the required UDF's here
;
...




Here is the INI file:




AdminScriptEditor Script Conversion




;*************************************************************************
;
AUTHOR Wim Rotty
;
;
INI file to be used with GPO-Machine-StartupScript-Installations.kix
;
;
[Section]
;
contains friendly name
;
Tip: refer to the DisplayName data under the Uninstall key
;
;
NetworkID
;
Network or networks where computer should be to allow software installation
;
The format of the list of networks should be build like this
;
xxx.xxx.xxx.xxx/yy;xxx.xxx.xxx.xxx/yy;xxx.xxx.xxx.xxx/yy
;
where xxx.xxx.xxx.xxx is the NetworkID and yy is the Net Mask
;
preceeding zero's should not be used
;
In example:
;
NetworkID=192.168.1.0/24;172.16.0.0/27
;
;
UninstallRegKey
;
Registry Key found under
;
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
;
;
DisplayVersion
;
Value of the DisplayVersion Data as written by the package
;
;
Server
;
Computer where installation package can be found
;
;
Path
;
share and Path on server where package can be found
;
must start and end with a backslash ("\")
;
;
File
;
File of executable to be launched
;
;
Switches
;
Switches required by the installation
;

;
*************************************************************************

[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"