我对此环境很安静,我的问题是,我使用7z压缩文件,但是你能帮我解决如何使用.zip扩展吗?由于我是关于批处理的假人,我只是创建了环境变量,我可以将移动文件从一个复制到另一个。但是获取带有zip扩展名的文件对我来说很难。我一直在搜索它。此外,我还有另一个关于这个批次的问题,我可以在我自己的Windows 7操作系统计算机上运行它,但我不能对我的客户计算机做同样的事情,我想在Microsoft SQL Server 2012上运行这个脚本,顺便说一下主文件夹的名称有空格,我也得到错误。
echo off
if not exist "C:\Pack" mkdir %genericPath%\Pack
if not exist "C:\ProAgent" mkdir %genericPath%\Pack\ProAgent
if not exist "C:\ProAgent1230" mkdir %genericPath%\Pack\ProAgent1230
xcopy /b /v /y /s %genericPath%\Filter-Inventory\filter.ini %genericPath%\Pack\ProAgent
xcopy /b /v /y /s %genericPath%\Filter-Inventory\pvinvent.ini %genericPath%\Pack\ProAgent
xcopy /b /v /y /s %genericPath%\Registry\updateProAgent.reg %genericPath%\Pack\ProAgent1230
xcopy /b /v /y /s %genericPath%\Files\$update$.bat %genericPath%\Pack\ProAgent1230
xcopy /b /v /y /s %genericPath%\Files\runscript.vbs %genericPath%\Pack\ProAgent1230
xcopy /b /v /y /s %genericPath%\Files\runupdate.bat %genericPath%\Pack\ProAgent1230
xcopy /b /v /y /s %genericPath%\Files\updateAgent.cmd %genericPath%\Pack\ProAgent1230
:Archieve
set archievePatch= %genericPath%\Pack
7z.exe a %genericPath%\Pack "%archievePatch%"
rmdir /s /q "%genericPath%\Pack"
PATH %genericPath%\FF
exit
答案 0 :(得分:0)
您需要指定输出类型:
7z.exe a -tzip %genericPath%\Pack "%archievePatch%"\
可替换地:
7z.exe a %genericPath%\Pack.zip "%archievePatch%"\
(注意:源上的反斜杠是必要的,因为它表示文件夹)
查看这些网站:
7zip命令的示例:http://www.dotnetperls.com/7-zip-examples
压缩文件夹:http://www.wikihow.com/Use-7Zip-to-Create-Multiple-Compressed-Folders-in-One-Go
答案 1 :(得分:0)
谢谢你的帮助。我已经配置了脚本,现在我可以使用下面给出的脚本获得Pack.zip。但是我不能在客户的电脑上做同样的事情。当我在环境变量上定义特定路径时,它不起作用。目标文件夹位于名为Win Nix的主文件夹中,当我尝试创建此zip文件时,它只是创建了一个名为Nix且没有zip的文件,没有包含复制的文件。我该如何解决这个问题?
谢谢
echo off
if not exist "C:\Pack" mkdir %genericPath%\Pack
if not exist "C:\ProAgent" mkdir %genericPath%\Pack\ProAgent
if not exist "C:\ProAgent1230" mkdir %genericPath%\Pack\ProAgent1230
xcopy /b /v /y /s %genericPath%\Filter-Inventory\filter.ini %genericPath%\Pack\ProAgent
xcopy /b /v /y /s %genericPath%\Filter-Inventory\pvinvent.ini %genericPath%\Pack\ProAgent
xcopy /b /v /y /s %genericPath%\Registry\updateProAgent.reg %genericPath%\Pack\ProAgent1230
xcopy /b /v /y /s %genericPath%\Files\$update$.bat %genericPath%\Pack\ProAgent1230
xcopy /b /v /y /s %genericPath%\Files\runscript.vbs %genericPath%\Pack\ProAgent1230
xcopy /b /v /y /s %genericPath%\Files\runupdate.bat %genericPath%\Pack\ProAgent1230
xcopy /b /v /y /s %genericPath%\Files\updateAgent.cmd %genericPath%\Pack\ProAgent1230
set archievePatch= %genericPath%\Pack
echo Set objArgs = WScript.Arguments > _zipIt.vbs
echo InputFolder = objArgs(0) >> _zipIt.vbs
echo ZipFile = objArgs(1) >> _zipIt.vbs
echo CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" ^& Chr(5) ^& Chr(6) ^& String(18, vbNullChar) >> _zipIt.vbs
echo Set objShell = CreateObject("Shell.Application") >> _zipIt.vbs
echo Set source = objShell.NameSpace(InputFolder).Items >> _zipIt.vbs
echo objShell.NameSpace(ZipFile).CopyHere(source) >> _zipIt.vbs
echo wScript.Sleep 2000 >> _zipIt.vbs
CScript _zipIt.vbs %archievePatch% %genericPath%\Pack.zip
rmdir /s /q "%genericPath%\Pack"
exit