Dear sir,
I've some backed up files from variuous locations stored in a folder c:\data
and i want to back fiels in that folder to a single file c:\data.zip

i used :
-============
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFolders = objWMIService.ExecQuery _
("Select * From Win32_Directory Where Name = 'C:\DBsBackup'")
For Each objFolder in colFolders
errResults = objFolder.Compress
Next
-============
i just need any kind of scripts to make it in scheduled task
but didn't work, any help ?

thanks
A. Sabry

Re: Compress Folder to a single file? by Pegasus

Pegasus
Sun May 11 10:45:53 CDT 2008


"Ahmad" <adsf@dsf.c> wrote in message
news:eyBBMo3sIHA.1316@TK2MSFTNGP06.phx.gbl...
> Dear sir,
> I've some backed up files from variuous locations stored in a folder
> c:\data and i want to back fiels in that folder to a single file
> c:\data.zip
>
> i used :
> -============
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
> Set colFolders = objWMIService.ExecQuery _
> ("Select * From Win32_Directory Where Name = 'C:\DBsBackup'")
> For Each objFolder in colFolders
> errResults = objFolder.Compress
> Next
> -============
> i just need any kind of scripts to make it in scheduled task
> but didn't work, any help ?
>
> thanks
> A. Sabry

The Compress method compresses all files in the specified
folder. It does not "zip" them up. You should also modify your
code like so:
("Select * From Win32_Directory Where Name = 'C:\\DBsBackup'")

Have a look here why one single post, perhaps cross-posted, is
much better than the multiple posts you made:
http://www.blakjak.demon.co.uk/mul_crss.htm



Re: Compress Folder to a single file? by James

James
Mon May 19 21:12:02 CDT 2008

"Ahmad" <adsf@dsf.c> wrote in message
news:eyBBMo3sIHA.1316@TK2MSFTNGP06.phx.gbl...
> Dear sir,
> I've some backed up files from variuous locations stored in a folder
> c:\data and i want to back fiels in that folder to a single file
> c:\data.zip
>
> i used :
> -============
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
> Set colFolders = objWMIService.ExecQuery _
> ("Select * From Win32_Directory Where Name = 'C:\DBsBackup'")
> For Each objFolder in colFolders
> errResults = objFolder.Compress
> Next
> -============
> i just need any kind of scripts to make it in scheduled task
> but didn't work, any help ?
>
> thanks
> A. Sabry

See if the code below will do what you want. I borrowed heavily from:
www.ureader.com/message/760555.aspx

The possible problem that I see is in the code that waits for the
process to complete. It watches for 'wscript.exe' processor usage to be at 0
for 3 seconds. If there is only a single copy of 'wscript.exe' running, it
works, but if there is a second copy running, it could cause the compression
script to terminate early. Hopefully someone else in the group with more
experience with monitoring processes can offer a more reliable solution.

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sFolder = "C:\DBsBackup"

Set oSHL = CreateObject("Shell.Application")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sBlankZip = "PK" & Chr(5) & Chr(6) & String(18, Chr(0))
Set oFolder = oFSO.GetFolder(sFolder)

For Each oSubFolder in oFolder.SubFolders
oFSO.OpenTextFile(oSubFolder & ".zip", 2, True).Write sBlankZip
Set oDestFldr = oSHL.NameSpace(oSubFolder & ".zip")
oDestFldr.CopyHere(oSubFolder & "\")
Next

With
GetObject("winmgmts:Win32_PerfFormattedData_PerfProc_Process.Name='wscript'")
Do While Counter < 2
.Refresh_: WScript.Sleep 1000
If .PercentProcessorTime = 0 Then Counter = Counter + 1 Else Counter = 0
Loop
End With
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note: This is my 6th attempt to post this message. For some reason, the post
is not appearing. SPAM filter mis-fire, perhaps??