【发布时间】:2014-06-19 08:12:26
【问题描述】:
我正在测试一个小脚本来压缩文件,我使用“PowerGUI 脚本编辑器”将脚本编译为可执行文件,一切正常,但是当你去运行时。 exe并压缩文件,显示进度条,我想知道如何隐藏指示压缩的进度条,我的代码是:
$srcdir = mysourcedir
$zipFilename = \zipfilename
$zipFilepath = $env:temp
$zipFile = "$zipFilepath$zipFilename"
#Prepare zip file
if(-not (test-path($zipFile))) {
set-content $zipFile ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
(dir $zipFile).IsReadOnly = $false
}
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipFile)
$files = Get-ChildItem -Path $srcdir
foreach($file in $files) {
$ProgressPreference = ’SilentlyContinue’
$zipPackage.CopyHere($file.FullName)
#using this method, sometimes files can be 'skipped'
#this 'while' loop checks each file is added before moving to the next
while($zipPackage.Items().Item($file.name) -eq $null){
$ProgressPreference = ’SilentlyContinue’
Start-sleep -seconds 1
}
}
我要隐藏的进度条是这样的:
http://i.stack.imgur.com/LlUVQ.png
我真的需要帮助,希望有人能帮我解决我的问题,谢谢
【问题讨论】:
标签: powershell compression zipfile