【问题标题】:Copy files and put into zip file from batch file or windows command line从批处理文件或 Windows 命令行复制文件并放入 zip 文件
【发布时间】:2016-03-24 09:28:37
【问题描述】:

如何从本地网络中的另一台计算机复制文件并将它们保存为本地计算机中的 zip 文件? 有没有办法直接使用 xcopy、robocopy 或类似程序压缩文件?

【问题讨论】:

    标签: windows powershell command-line zip


    【解决方案1】:

    从 Powershell 角度回答:

    在 V5 之前有几种使用 Powershell 压缩文件的实现,在 V5 中有一个 cmdlet compress-archive

    Here 您可以找到指向您的问题的类似链接(本地来源,unc dest),但反过来应该也一样。

    【讨论】:

      【解决方案2】:

      如果两台电脑都安装了powershell,则只需执行以下代码即可。

      Legit credentials = new credentials.
      $s = New-PSSession -ComputerName RemotePc -Credential LegitCredentials
      Invoke-Command -Session $s -ScriptBlock 
      {
       Add-Type -assembly "system.io.compression.filesystem"
       [io.compression.zipfile]::CreateFromDirectory($SourcePath,$destinationPath)
       Move-item from $destinationPath to sharedPath
       Move-item from sharedpath to localpath
      }
      

      【讨论】:

        猜你喜欢
        • 2012-07-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-12-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多