I wanted to use WPKG to deploy digestIT 2004. DigestIT 2004 is a free Windows program that will allow you to generate a MD5 message hash, aka MD5 sum or MD5 hash, for any file on a system. Once the program is installed, you can right-click on a file and choose "digestIT 2004" and then "Calculate MD5 Hash" to generate a unique identifying hash for a file, which you can copy to the clipboard. The number that is generated is a sequence of hexadecimal numbers, i.e. it can contain the numbers 0 to 9 plus the characters A through F, which represent the numbers 10 through 15 in hexadecimal. The MD5 hash should be unique for any file you choose. The odds that two files would have the same hash are extremely small. With MD5 hashes you can tell if a file has been changed, if you know its original hash. If the contents of a file are modified in any way, the MD5 hash will no longer be the same.
So I downloaded digestIT_2004.zip, extracted digestIT 2004.msi from within it and placed it within "\wpkg\pkg\digestIT2004" on the server. I updated WPG's profiles.xml file on the server in the "\wpkg" directory to include the following line:
<package package-id="digestIT2004" />
I then updated the packages.xml fileto include install and uninstall commands for digestIT 2004. The final version of the code I used in packages.xml is shown below:
<package
id="digestIT2004"
name="digestIT 2004"
revision="1"
reboot="false"
priority="5">
<check type="uninstall" condition="exists" path="digestIT 2004" />
<install cmd='msiexec /i "\\s\wpkg\pkg\digestIT2004\digestIT 2004.msi" /qn'>
<exit code="0" />
</install>
<remove cmd='msiexec /x{5B119660-1788-11D8-8EB8-0050BF643EE7} /qn' />
</package>
Note: If you wish to specify the installation directory for digestIT 2004, you can use an entry similar to the following in packages.xml:
<install cmd='msiexec /i "\\s\wpkg\pkg\digestIT2004\digestIT 2004.msi"
/qn TARGETDIR="%PROGRAMFILES%\Utilities\File\digestIT 2004"'>
<exit code="0" />
</install>
In the example above, "s" is the server name. For "TARGETDIR" enter the directory in which you want to install digestIT 2004. Put the directory name in quotes. There should be a single quote after the double quotes. You could put in something like "C:\Program Files\Utilities\Files\digestIT 2004" or you can use the variable %PROGRAMFILES% instead. Any subdirectories that don't exist will be created during the installation process.
I've found that installations of the software to Windows XP systems will result in a default installation to a "%PROGRAMFILES%\digestIT 2004" directory, but when I installed it with wpkg on a Windows 2000 system it went into "C:\", so I altered the install section of the packages.xml file to specify the installation directory.
When I first installed the software,
I installed the software from a client workstation by getting a command
prompt and issuing the command cscript /nologo \\s\wpkg\wpkg.js
/synchronize
. The nologo
option for cscript tells it
not to display its banner when it starts and the synchronize
option for wpkg.js tells it to synchronize the installed applications
on the Windows XP system on which I executed the command with the
server, i.e. update the XP system based on the contents of the hosts.xml, profiles.xml,
and packages.xml files on the server. That worked fine, but when I
tried to test the uninstall feature, I encountered problems. I then
used the /verbose
option for wpkg.js. I issued the command
cscript /nologo \\s\wpkg\wpkg.js /synchronize /verbose
,
which showed me the following error message.
removing package: digestIT2004
Removing digestIT 2004...
executing command : msiexec /e /x "\\s\wpkg\pkg\digestIT2004\digestIT 2004.msi"
"digestIT 2004.msi"
command returned result: 1601
checking existence of package:digestIT 2004
Checking presence of digestIT 2004; uninstall check condition met.
Errors occurred while removing digestIT 2004.
I originally had the following code in the digestIT 2004 section of packages.xml:
<remove cmd='msiexec /e /x "\\s\wpkg\pkg\digestIT2004\digestIT 2004.msi"
"digestIT 2004.msi"'>
<exit code="0"/>
</remove>
The code was wrong and I removed it after I realized it was wrong, but that was
after I installed the package. Yet, after I corrected the code and tested the
uninstall portion of it by removing the <package package-id="digestIT2004"
/>
line from profiles.xml, the incorrect line was still being executed.
To uninstall a package, you simply remove the package entry from the appropriate
profile section in profiles.xml, which was the "default" profile in this case.
The script was attempting to uninstall it, but I couldn't figure out why it kept
trying to execute the previous incorrect removal command even after I corrected it,
until I found a June
9 2005 post by Jerry Haltom at a SourceForge wpkg forum in regards to upgrading
Firefox that provided an explanation as to what was happening.
From: Jerry Haltom <wasabi@la...>rvalstage.net> Re: Package updating 2005-06-09 19:55 When a package is installed it"s entire <package> stanza is copied into wpkg.xml in the Windows system directory. When a package is removed, the remove command listed in the wpkg.xml file, that was put there previously, is run. This is so that you can delete a package from wpkg and not have to worry about keeping it"s old history around... the hosts will have it until it"s gone from every host. When a package is upgraded, ie a new revision exists in packages.xml from what is currently installed in wpkg.xml, the <upgrade> commands in packages.xml are run and the entry in wpkg.xml is replaced completely. You can use upgrade commands to first remove the old package, and then install the new. It is like this because a lot of the time you want to upgrade a package simly by running one command to replace one file... and some packages actually have decent upgrade procedures. Some don"t.
After reading the post, I checked the client system and found a wpkg.xml file
in the C:\Windows\system32 directory on that system that contained the old
incorrect code. I replaced the "remove" code in that file with <remove
cmd='msiexec /x{5B119660-1788-11D8-8EB8-0050BF643EE7} /qn' />
and then
tried to uninstall again. This time the uninstall worked.
C:\Program Files>cscript /nologo \\s\wpkg\wpkg.js /synchronize
Removing digestIT 2004...
Checking presence of digestIT 2004; uninstall check condition failed !
Removal of digestIT 2004 successful.
The "uninstall check condition failed" message above just indicates that it tested
for the presence of the software with the <check type="uninstall"
condition="exists" path="digestIT 2004" />
test, which attempts to
determine if the program appears in "Add or Remove Programs". Well actually it is
looking for the appearance of "digestIT 2004" registry key under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
.
Entries under that key are what apper when you go to "Start", "Control Panel, "Add
or Remove Programs".
I used <remove cmd='msiexec /x{5B119660-1788-11D8-8EB8-0050BF643EE7} /qn'
/>
, because you can remove software installed from .msi
files by using the command msiexec/x {Package | ProductCode}
, where
"Package" is the package name or by using the "ProductCode, which is a Globally
unique identifier (GUID) used by the Windows Installer package for that package.
In this case, I looked for a digestIT 2004 entry under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
and found it listed under a key named
{5B119660-1788-11D8-8EB8-0050BF643EE7}
, so I
knew that was the GUID for digestIT 2004 and the one I could use in the "remove
cmd" line in the packages.xml file.
References: