Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WSH Compress Folder
Message
De
25/08/2005 13:08:29
 
 
À
25/08/2005 12:43:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01043792
Message ID:
01043974
Vues:
14
Great

>Hi Greg. Many thanks for the input. I have worked out a solution as well.
>
>
>
>
>>Wait, here a better version. It work vary fast.
>>
>>
>>* Program:     WMI_FOLDER2.PRG
>>* Description:
>>* Created:     08/25/2005
>>* Developer:   Gregory L Reichert
>>* Resource:    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_directory.asp
>>*------------------------------------------------------------
>>SET STEP ON
>>
>>LOCAL lcComputer, loOutParams, loWMIService
>>
>>lcComputer = "."
>>loWMIService = GetObject("winmgmts:\\" + lcComputer + "\root\CIMV2")
>>
>>* Obtain the definition of the class.
>>objShare = loWMIService.Get("Win32_Directory")
>>
>>* Execute the method and obtain the return status.
>>* The OutParameters object in objOutParams
>>* is created by the provider.
>>loOutParams = loWMIService.ExecMethod( "Win32_Directory.Name='C:\\temp'", "Compress")
>>
>>? loOutParams.ReturnValue
>>
>>loOutParams = loWMIService.ExecMethod( "Win32_Directory.Name='C:\\temp'", "Uncompress")
>>
>>? loOutParams.ReturnValue
>>
>>RETURN
>>
>>
>>
>>
>>
>>
>>>>Hi All. What is the WSH command to compress a folder?
>>>
>>>This may not use the WSH classes, but it does do the job.
>>>
>>>
>>>* Program:     WMI_FOLDER.PRG
>>>* Description: Compress and Uncompress folders
>>>* Created:     08/25/2005
>>>* Developer:   Gregory L Reichert
>>>* Resource:    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_directory.asp
>>>*------------------------------------------------------------
>>>
>>>SET STEP ON
>>>IF NOT DIRECTORY("c:\temp")
>>>	MD c:\Temp
>>>	STRTOFILE("Hello World", "c:\temp\Test.txt")
>>>endif
>>>
>>>clear
>>>
>>>LOCAL lcComputer, lcolFolder, loObj, loWMIService
>>>
>>>lcComputer = "."
>>>loWMIService = GetObject("winmgmts:" +"{impersonationLevel=impersonate}!\\"+lcComputer+ "\root\cimv2")
>>>lcolFolder = loWMIService.ExecQuery ("Select * from Win32_Directory where Caption='c:\\Temp'")
>>>For Each loFolder in lcolFolder
>>>	?
>>>  	? "AccessMask=",loFolder.AccessMask
>>>  	? "Archive=",loFolder.Archive
>>>  	? "Caption=",loFolder.Caption
>>>  	? "Compressed=",loFolder.Compressed
>>>  	? "CompressionMethod=",loFolder.CompressionMethod
>>>  	? "CreationClassName=",loFolder.CreationClassName
>>>  	? "CreationDate=",loFolder.CreationDate
>>>  	? "CSCreationClassName=",loFolder.CSCreationClassName
>>>  	? "CSName=",loFolder.CSName
>>>  	? "Description=",loFolder.Description
>>>  	? "Drive=",loFolder.Drive
>>>  	? "EightDotThreeFileName=",loFolder.EightDotThreeFileName
>>>  	? "Encrypted=",loFolder.Encrypted
>>>  	? "EncryptionMethod=",loFolder.EncryptionMethod
>>>  	? "Extension=",loFolder.Extension
>>>  	? "FileName=",loFolder.FileName
>>>  	? "FileSize=",loFolder.FileSize
>>>  	? "FileType=",loFolder.FileType
>>>  	? "FSCreationClassName=",loFolder.FSCreationClassName
>>>  	? "FSName=",loFolder.FSName
>>>  	? "Hidden=",loFolder.Hidden
>>>  	? "InstallDate=",loFolder.InstallDate
>>>  	? "InUseCount=",loFolder.InUseCount
>>>  	? "LastAccessed=",loFolder.LastAccessed
>>>  	? "LastModified=",loFolder.LastModified
>>>  	? "Name=",loFolder.Name
>>>  	? "Path=",loFolder.Path
>>>  	? "Readable=",loFolder.Readable
>>>  	? "Status=",loFolder.Status
>>>  	? "System=",loFolder.System
>>>  	? "Writeable=",loFolder.Writeable
>>>	
>>>	? loFolder.Compress()			&& 0 if successful.
>>>	? loFolder.Uncompress() 			&& 0 if successful.
>>>	EXIT 	
>>>	
>>>NEXT
>>>
>>>RETURN
>>>
>>>
>>>P.S. It does take a little time for it to locate the folder at the FOR EACH statement.
Greg Reichert
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform