Using a Configuration Group to Check Size of a File



The information in this article applies to: Prism Suite, Prism Deploy

 

Problem:

It would be useful to have a configuration group that checks for the size of a particular file. For example, file size can sometimes be used to determine what version of an application is installed. However, there currently isn’t a user-defined parameter to check for file size.

 

Resolution:

NBT Support has come up with a workaround using a VB script. The process is to create and run a VB script that captures the size of the file and writes that information to an INI file. You can then use the INI file in a configuration group ruleset to see the file’s size. In our example below, we’re checking the size of the Prism client file.

 

First, use notepad to create a .vbs script with the lines shown below. On line 1, specify the path to the file you're interested in. On line 5, specify the path and file name for the INI file that will be created.

 

Const filename = "C:\Program Files\New Boundary\Client\PTClient.exe"

Dim objFSO, objFile, objINIFile

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.GetFile(filename)

Set objINIFile = objFSO.CreateTextFile("C:\Program Files\New Boundary\Client\PTClientsize.ini",2)

objINIFile.WriteLine "[PTClient size]"

objINIFile.WriteLine "bytes="& objFile.Size

objFile.Close

 

This script will calculate the size of the "C:\Program Files\New Boundary\Client\PTClient.exe" file and then store the value in a file called PTClientsize.ini in the C:\Program Files\New Boundary\Client folder. You can assign the script.vbs to all your machines as a command Task.  The format of this Task would look something like "cscript \\server\share\script.vbs".  After the Task has run, each machine will have an INI file created in the C:\Program Files\New Boundary\Client folder that tells how big each machine's PTClient.exe file actually is.

           

The next step is to create a User-defined Configuration Group to query the INI file. For example:

 

<INI Value> "C:\Program Files\New Boundary\Client\PTClientsize.ini\\PTClient size\\bytes" = "2097152"

 

This Configuration Group will then populate with any computer that has an INI file named PTClientsize.ini in the C:\Program Files\New Boundary\Client folder and has a bytes value equal to 2097152. Note that the odds are not very good that PTClient.exe is exactly 2MB (2097152 bytes) in size.  You may want to look at a few copies of the file and note what the size in bytes is.  That way you could create a configuration group that checks for a range like > 2000000 and < 2200000.