我有一个我在powershell中编写的脚本,它根据服务器上的版本检查本地计算机上的程序版本。如果有新版本,则通过从服务器复制文件来更新本地计算机。该脚本工作正常,但复制文件大约需要一分钟,我想显示某种进度条。
Add-Type –AssemblyName System.Windows.Forms
$source = "G:\ERP\ERP.ade"
$destination = "C:\ERP\ERP.ade"
$sourceVersionFile = "G:\ERP\Version.txt"
$destinationVersionFile = "C:\ERP\Version.txt"
$sourceVersion = get-content $sourceVersionFile
$destinationVersion = get-content $destinationVersionFile
$sourceVersion -as [double]
$destinationVersion-as [double]
if ($sourceVersion-gt $destinationVersion){
$OUTPUT= [System.Windows.Forms.MessageBox]::Show("There is a new version of the ERP Available. Download it now?" , "Update ERP?" , 4)
if ($OUTPUT -eq "YES" )
{
Copy-Item $source $destination
Copy-Item $sourceVersionFile $destinationVersionFile
}
else
{
[System.Windows.Forms.MessageBox]::Show("The ERP was not updated." , "ERP not Updated.")
}
}