Is it possible to Set & Get "CUSTOM" file properties with Powershell.
I am not interested in 'Extended' file properties, at least not the pre-existing extended file properties. What I am talking about is the file properties I can add through the Windows File Properties GUI dialog on the "Custom" tab.
On the Custom tab, I can create my own file property name and set its Type ( Text, Date, Number, Yes/No ) and its Value.
I am not working with Microsoft Office Documents, MP3, JPG's or other common file types. I am working with files produced from commericial application: Proficy HMI / Cimplicity, but that should not matter as the custom properties are set by Microsoft Windows, and not by the Cimplicity application. I use the Cimplicity application to create "source" code for the file ( extention is *.cim ), and then also use the app to "compile" the file into a runtime version ( *.cimrt )
My file has an extention of .cimrt. Using the File Propereties GUI dialog, I created three custom properties:
Version : Text : 3.1.2469
Build : Text : ( TFS Build name and number )
Changeset : Number : 54849
Using a hex editor, I can see that Windows writes this information into the file.
What I would really like to be able to do is to create a Powershell script that injects these 3 properties into the cimrt file.
This post has gotten me close: Enumerate file properties in PowerShell but all I can see are extended file properties.
$shell = New-Object -COMObject Shell.Application
$myfile = Get-ChildItem "screen.cimrt"
$file = $myfile.Name
$path = $myfile.DirectoryName
$shellfolder = $shell.Namespace($path)
$shellfile = $shellfolder.ParseName($file)
The example shows looping through the property ID numbers. I did that and extended the loop to 1024 and dumped it all to the console. I did not find my new custom properties. I then said to myself, lets let the computer do the work:
0..32767 | %{
$value = $shellfolder.GetDetailsOf($shellfile, $_)
if ( $value -eq 54849 ) { $_, $shellfolder.GetDetailsOf($null, $_), $shellfolder.GetDetailsOf($shellfile, $_) }
}
54849 was the value I set for the Changeset. 32767 was a riduculously large enough number, or so I assume. The value was never found.
$shellfile | Get-Member
produced :
Name MemberType Definition
---- ---------- ----------
ExtendedProperty Method Variant ExtendedProperty (string)
InvokeVerb Method void InvokeVerb (Variant)
InvokeVerbEx Method void InvokeVerbEx (Variant, Variant)
Verbs Method FolderItemVerbs Verbs ()
Application Property IDispatch Application () {get}
...
I tried :
$shellfile.ExtendedProperty("Version")
$shellfile.ExtendedProperty("Changeset")
$shellfile.ExtendedProperty("Build")
and got nothing. ( or rather $null )
$shellfile.ExtendedProperty("Owner")
produced "Administrators"
$shellfile.Verbs listed the items I could invoke when I right click the file from Explorer. I tried $shellfile.InvokeVerb('Properties') and just got the same MS GUI properties dialog.
Where can I go from here?