Page 1 of 1 1
Topic Options
#177953 - 2007-07-14 03:07 AM Group Policy Computer Startup Software Installation Script
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
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"



Top
#177954 - 2007-07-14 03:24 AM Re: Group Policy Computer Startup Software Installation Script [Re: Witto]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
This script checks very quick if certain "non MSI" packed software is installed. Only if install or upgrade is required, and if the computer is present in certain networks (the local network), the software is installed.
Do not hesitate to comment or to give script modification proposals.
in example:
  • Maybe uninstall of a previous package is required
  • Maybe it can be extended to other type of installers like msi
  • Maybe "installation" of separate files or registration of DLL's can be included
  • Maybe the script can be golfed a bit (but not too much...)
  • Maybe we want some logging so we see which computer gets the software installed

Top
#186033 - 2008-03-07 04:10 AM Re: Group Policy Computer Startup Software Installation Script [Re: Witto]
estrada Offline
Fresh Scripter

Registered: 2005-03-27
Posts: 19
I like your script. CAn you tell me if this was ever completed where you can uninstall a previous package and enable logging for success or failures.

I am trying to uninstall MSI from many machines and need then upgrade to latest version

Top
#186061 - 2008-03-08 11:47 AM Re: Group Policy Computer Startup Software Installation Script [Re: estrada]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Do you want to distribute the Windows Installer 3.0?
IIWY, I would not uninstall the old version first. IMHO, Microsoft wouldn't be Microsoft if they would not succeed to update their Installer in a decent way.
I think you want to look for the key "KB893803v2" and the DisplayVersion "3.1".
The script is still as it is in the first post.

Top
#213409 - 2018-06-19 11:36 AM Re: Group Policy Computer Startup Software Installation Script [Re: Witto]
Patxicla Offline
Just in Town

Registered: 2018-06-19
Posts: 1
Loc: Guipúzcoa
Hi witto: I've tried to use your script to install Citrix receiver in a Computer group Policy, but I get error in line 42 >> Expected ")"!

Line 42 is
$strNetworkID = Split(ReadProfileString($INI, $Section, "NetworkID"), ";")

I'm only using one IP network in the INI file.
I don't know what is wrong. I'm new with KIX and my scripting knowledge is very poor. Any help would be much appreciated.

Thanks a lot.

Top
#213411 - 2018-06-19 06:37 PM Re: Group Policy Computer Startup Software Installation Script [Re: Patxicla]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Without seeing your ini file, I'm guessing you don't have a ; at the end of the value. The code is converting the string to an array, and without the ; it doesn't convert.
Top
#213454 - 2018-06-26 04:35 PM Re: Group Policy Computer Startup Software Installation Script [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
there is no examples in this pseudo UDF code.

it seems that he is wanting the user to somehow plug in the ini file and section inside this script...

without trying it out myself, I couldn't honestly say for sure but I think in Patxicla's case there might actually be something wrong on line 41 or even before that.
_________________________
!

download KiXnet

Top
#213470 - 2018-06-28 02:36 PM Re: Group Policy Computer Startup Software Installation Script [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
I'm also thinking that there's a code issue on a prior line. The following simple test shows that the ";" or even multiple entries in the split isn't necessary:
 Code:
$ = 'stuff'
$a = Split($, ';')
UBound($a) ' elements.' ?
I'd suggest posting the code if it's been changed in any way and the INI file.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 255 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.232 seconds in which 0.161 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org