This seems to do the trick. Let me know how it works and I'll post it to the UDF forum...
Code:
; ======================================================================
;
; fnCompress - Uses WMI to compress files or folders
;
; NAME: fnCompress()
;
; AUTHOR: Christopher Shilt (christopher.shilt@relizon.com)
; DATE : 5/9/2004
;
; COMMENT:
;
; ========================================================================
Break On
fnCompress("D:\Target\tetrix") ?
;fnCompress("D:\Target\6to4svc.dll") ?
@ERROR " | " @SERROR ?
Function fnCompress($sTarget,Optional $sComputer)
Dim $objWMI,$colTarget
$sTarget = Join(Split($sTarget,"\"),"\\")
If Not $sComputer $sComputer=@WKSTA EndIf
$objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"+$sComputer+"\root\cimv2")
If @ERROR<0 Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf
If GetFileAttr($sTarget) & 16
$colTarget = $objWMI.ExecQuery("Select * from CIM_Directory where name = '" + $sTarget + "'")
$fnCompress = 3
For Each $sTarget in $colTarget
$fnCompress = $sTarget.Compress
Next
Else
$colTarget = $objWMI.ExecQuery("Select * from CIM_Datafile where name = '" + $sTarget + "'")
$fnCompress = 2
For Each $sTarget in $colTarget
$fnCompress = $sTarget.Compress
Next
EndIf
Exit($fnCompress)
EndFunction