如何使用cmd解压缩文件? [英] how to unzip file using cmd ?

查看:148
本文介绍了如何使用cmd解压缩文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是VbScript的新手,我想要复制zip文件并将其解压缩的vbscript。



i使用此代码

  Sub  ExtractFile(objFSO,lastImportDate,zipFilePath)
DIM subFolderPath
subFolderPath = \ developer \
DIM dumpFile
dumpFile = fichero.dump
Dim extractTo
extractTo = C:\DB importer - Copy\\db-backup -

extractTo = extractTo + lastImportDate

' 如果提取位置不存在,请创建它。
设置 fso = CreateObject( Scripting.FileSystemObject
如果 NOT fso.FolderExists(extractTo)那么
fso.CreateFolder(extractTo )
结束 如果

' 提取zip文件的内容。
set objShell = CreateObject( Shell.Application
set FilesInZip = objShell。 NameSpace (zipFilePath).items // error
objShell。 NameSpace (extractTo).CopyHere(FilesInZip)
Set fso = Nothing
设置 objShell = Nothing
结束 Sub





但在//错误时给出错误

所需对象:'objShell .NameSpace(...)'



这个vbscript可以在任何电脑上运行。



如果有的话有解决方案,请尽快回复。

谢谢。

解决方案

查看此链接以供参考Easily-zip-unzip-files

<预lang =xml>这里我只做这些
< pre lang = vb >
Dim objShell
set objShell = CreateObject(Shell.Application)
objShell.NameSpace(extractTo).CopyHere objShell.NameSpace(extractFrom).Items
< / pre >

而不是这些
< pre lang = vb >
set objShell = CreateObject(Shell.Application)
set FilesInZip = objShell.NameSpace(zipFilePath).items // error
objShell.NameSpace(extractTo).CopyHere(FilesInZip )
< / pre >

并在extractTo路径中添加\。
谢谢。


I am new in VbScript , and i want to vbscript which will copy zip file and extract it.

i have used this code

Sub ExtractFile(objFSO,lastImportDate,zipFilePath)
        DIM subFolderPath
	subFolderPath = "\developer\"
	DIM dumpFile
	dumpFile = "fichero.dump"
	Dim extractTo
	extractTo = "C:\DB importer - Copy\\db-backup-" 
	
	extractTo = extractTo + lastImportDate

	'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(zipFilePath).items //error
	objShell.NameSpace(extractTo).CopyHere(FilesInZip)
	Set fso = Nothing
	Set objShell = Nothing
End Sub



but its giving error at // error
Object required: 'objShell.NameSpace(...)'

This vbscript should run on any pc.

If any have solution , reply as soon as possible.
Thank you.

解决方案

view this link for reference Easily-zip-unzip-files


Here i just do these
<pre lang="vb">
Dim objShell
set objShell = CreateObject("Shell.Application")
objShell.NameSpace(extractTo).CopyHere objShell.NameSpace(extractFrom).Items
</pre>

instead of these
<pre lang="vb">
set objShell = CreateObject("Shell.Application")
set FilesInZip=objShell.NameSpace(zipFilePath).items //error
objShell.NameSpace(extractTo).CopyHere(FilesInZip)
</pre>

and add "\" in extractTo path.
Thank you.


这篇关于如何使用cmd解压缩文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆