PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.win.server.scripting > How to create ZIP Files from Command-Line via VBScript?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
How to create ZIP Files from Command-Line via VBScript?

Réponse
 
LinkBack Outils de la discussion
Vieux 07/07/2008, 19h50   #1
FB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to create ZIP Files from Command-Line via VBScript?

Ho can i create Zip Files via command-line?
Can be done via WMI?

I don´t wann use WinZIP COmmand Line Add-On, because it is not freeware

Can i use VBScript to do that? Other "Lnaguage" maybe?
  Réponse avec citation
Vieux 07/07/2008, 20h20   #2
Wayne Tilton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to create ZIP Files from Command-Line via VBScript?

=?Utf-8?B?RkI=?= <FB@discussions.microsoft.com> wrote in news:BA2EBF27-
A76A-487C-8837-90D9D1BD8168@microsoft.com:

> Ho can i create Zip Files via command-line?
> Can be done via WMI?
>
> I don´t wann use WinZIP COmmand Line Add-On, because it is not freeware
>
> Can i use VBScript to do that? Other "Lnaguage" maybe?
>


How about a free command line ZIP utility instead of WinZIP?

http://www.info-zip.org/

HTH,

Wayne Tilton
  Réponse avec citation
Vieux 07/07/2008, 20h52   #3
LJB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to create ZIP Files from Command-Line via VBScript?


"FB" <FB@discussions.microsoft.com> wrote in message
news:BA2EBF27-A76A-487C-8837-90D9D1BD8168@microsoft.com...
> Ho can i create Zip Files via command-line?
> Can be done via WMI?
>
> I don´t wann use WinZIP COmmand Line Add-On, because it is not freeware
>
> Can i use VBScript to do that? Other "Lnaguage" maybe?


Since Windows already knows how to deal with zip files to some extent you
might want to try the following. No external programs are needed. Believe it
or not the wscript.sleep at the end is important to make this work
correctly.

Const FOF_CREATEPROGRESSDLG = &H0&

Const MyZip = "C:\..\MyZipFile.zip"

Const File1 = "C:\..\File1.txt"
Const File2 = "C:\..\File2.txt"

Const MyDest = "C:\scratch"

'-------------- create empty zip file ---------

'Create the basis of a zip file.
CreateObject("Scripting.FileSystemObject") _
.CreateTextFile(MyZip, True) _
.Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)


'-------------- zip ---------------------------

'get ready to add files to zip
With CreateObject("Shell.Application")

'add files
.NameSpace(MyZip).CopyHere File1, FOF_CREATEPROGRESSDLG

.NameSpace(MyZip).CopyHere File2

End With
wScript.Sleep 1000


  Réponse avec citation
Vieux 07/07/2008, 20h58   #4
LJB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to create ZIP Files from Command-Line via VBScript?


"LJB" <postmaster@[127.0.0.1]> wrote in message
news:Odh9kKG4IHA.1952@TK2MSFTNGP03.phx.gbl...
>
> "FB" <FB@discussions.microsoft.com> wrote in message
> news:BA2EBF27-A76A-487C-8837-90D9D1BD8168@microsoft.com...
>> Ho can i create Zip Files via command-line?
>> Can be done via WMI?
>>
>> I don´t wann use WinZIP COmmand Line Add-On, because it is not freeware
>>
>> Can i use VBScript to do that? Other "Lnaguage" maybe?

>


Here is some info you may find useful too
http://www.rondebruin.nl/windowsxpzip.htm


  Réponse avec citation
Vieux 07/07/2008, 22h52   #5
FB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to create ZIP Files from Command-Line via VBScript?

Tanks, i´ll try it
In this forum i found another Tip, in creating a Blank ZIP file with "PK"
bytes and 17 bytes with CHR(0)

I´ll try to see

============================================
Set Ag=Wscript.Arguments
username = CreateObject("Wscript.Shell").Environment("Process ")("username")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts =
fso.OpenTextFile(FilePath&"_forms\workforus\_uploa ds\"&"form_data.zip", 2,
vbtrue)
BlankZip = "PK" & Chr(5) & Chr(6)
For x = 0 to 17
BlankZip = BlankZip & Chr(0)
Next
ts.Write BlankZip
set objFolder = nothing
set objShell = nothing
Set fso = nothing
Set ts = nothing

Set objShell = CreateObject("Shell.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set
DestFldr=objShell.NameSpace(FilePath&"_forms\workf orus\_uploads\"&"form_data.zip")
Set SrcFldr=objShell.NameSpace(FilePath&"_forms\workfo rus\_csv")
DestFldr.CopyHere (FilePath&"_forms\workforus\_csv")
============================================







"LJB" wrote:

>
> "FB" <FB@discussions.microsoft.com> wrote in message
> news:BA2EBF27-A76A-487C-8837-90D9D1BD8168@microsoft.com...
> > Ho can i create Zip Files via command-line?
> > Can be done via WMI?
> >
> > I don´t wann use WinZIP COmmand Line Add-On, because it is not freeware
> >
> > Can i use VBScript to do that? Other "Lnaguage" maybe?

>
> Since Windows already knows how to deal with zip files to some extent you
> might want to try the following. No external programs are needed. Believe it
> or not the wscript.sleep at the end is important to make this work
> correctly.
>
> Const FOF_CREATEPROGRESSDLG = &H0&
>
> Const MyZip = "C:\..\MyZipFile.zip"
>
> Const File1 = "C:\..\File1.txt"
> Const File2 = "C:\..\File2.txt"
>
> Const MyDest = "C:\scratch"
>
> '-------------- create empty zip file ---------
>
> 'Create the basis of a zip file.
> CreateObject("Scripting.FileSystemObject") _
> .CreateTextFile(MyZip, True) _
> .Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)
>
>
> '-------------- zip ---------------------------
>
> 'get ready to add files to zip
> With CreateObject("Shell.Application")
>
> 'add files
> .NameSpace(MyZip).CopyHere File1, FOF_CREATEPROGRESSDLG
>
> .NameSpace(MyZip).CopyHere File2
>
> End With
> wScript.Sleep 1000
>
>
>

  Réponse avec citation
Vieux 08/07/2008, 02h28   #6
FB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to create ZIP Files from Command-Line via VBScript?

It works great for small files, for large files i´ve added a Wscript.Echo
(Modal Button, with OK) and ionly works if i click the OK button after the
Zip proccess ( i can see a dialog box with a gauge indicating that the zipins
in on the way

Maybe it be necessary to use a higher number in the sleep directive


"LJB" wrote:

>
> "LJB" <postmaster@[127.0.0.1]> wrote in message
> news:Odh9kKG4IHA.1952@TK2MSFTNGP03.phx.gbl...
> >
> > "FB" <FB@discussions.microsoft.com> wrote in message
> > news:BA2EBF27-A76A-487C-8837-90D9D1BD8168@microsoft.com...
> >> Ho can i create Zip Files via command-line?
> >> Can be done via WMI?
> >>
> >> I don´t wann use WinZIP COmmand Line Add-On, because it is not freeware
> >>
> >> Can i use VBScript to do that? Other "Lnaguage" maybe?

> >

>
> Here is some info you may find useful too
> http://www.rondebruin.nl/windowsxpzip.htm
>
>
>

  Réponse avec citation
Vieux 08/07/2008, 02h30   #7
FB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to create ZIP Files from Command-Line via VBScript?


What´s the purpose of the Const MyDest = "C:\scratch"???
In any circunstances this line is used for something?

"LJB" wrote:

>
> "LJB" <postmaster@[127.0.0.1]> wrote in message
> news:Odh9kKG4IHA.1952@TK2MSFTNGP03.phx.gbl...
> >
> > "FB" <FB@discussions.microsoft.com> wrote in message
> > news:BA2EBF27-A76A-487C-8837-90D9D1BD8168@microsoft.com...
> >> Ho can i create Zip Files via command-line?
> >> Can be done via WMI?
> >>
> >> I don´t wann use WinZIP COmmand Line Add-On, because it is not freeware
> >>
> >> Can i use VBScript to do that? Other "Lnaguage" maybe?

> >

>
> Here is some info you may find useful too
> http://www.rondebruin.nl/windowsxpzip.htm
>
>
>

  Réponse avec citation
Vieux 08/07/2008, 14h21   #8
LJB
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to create ZIP Files from Command-Line via VBScript?


"FB" <FB@discussions.microsoft.com> wrote in message
news:A90AC5DD-C39D-4328-BEFE-8F38912C9A48@microsoft.com...
>
> What´s the purpose of the Const MyDest = "C:\scratch"???
> In any circunstances this line is used for something?
>
> "LJB" wrote:
>


Const MyDest = "C:\scratch" was something I used and forgot to remove before
sending the example.


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h25.


Édité par : vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13524 seconds with 16 queries