2009-05-26 12 views
10

Voglio decomprimere un file .zip usando VBScript, solo che è sempre un nuovo computer senza applicazioni esterne. Ora so che Windows XP e 2003 hanno un'opzione di cartella zip interna, quindi suppongo di poterlo usare tramite VBScript per estrarre il file.Come decomprimere un file in VBScript utilizzando le opzioni interne di Windows XP in

Come faccio?

ho provato:

Set objShell = CreateObject("Shell.Application") 

Set SrcFldr = objShell.NameSpace(fileName) 
Set DestFldr = objShell.NameSpace(appDir) 
DestFldr.CopyHere(SrcFldr) 

che non ha funzionato. Quale potrebbe essere il problema?

+0

Dai un'occhiata alla 3 ° ingresso in loco [Rob van der Woude] (http://www.robvanderwoude.com/vbstech_files_zip.php#CopyHereUNZIP). – bugmagnet

+0

controllare [this] (http://stackoverflow.com/questions/28043589/) – npocmaka

risposta

26

Basta impostare ZipFile = Il percorso del file zip e ExtractTo = nella posizione in cui deve essere estratto il file zip.

'The location of the zip file. 
ZipFile="C:\Test.Zip" 
'The folder the contents should be extracted to. 
ExtractTo="C:\Test\" 

'If the extraction location does not exist create it. 
Set fso = CreateObject("Scripting.FileSystemObject") 
If NOT fso.FolderExists(ExtractTo) Then 
    fso.CreateFolder(ExtractTo) 
End If 

'Extract the contants of the zip file. 
set objShell = CreateObject("Shell.Application") 
set FilesInZip=objShell.NameSpace(ZipFile).items 
objShell.NameSpace(ExtractTo).CopyHere(FilesInZip) 
Set fso = Nothing 
Set objShell = Nothing 
+2

Quando si scrive lo stesso in JScript è necessario fare attenzione a evitare le barre retroverse ("\\"). Quello mi ha dato un forte mal di testa. –

+0

Ottenere l'errore come oggetto Richiesto. msgstr "imposta FilesInZip = objShell.NameSpace (ZipFile) .items". Qualcuno può aiutarmi su questo –

Problemi correlati