Guest User

Untitled

a guest
Jan 23rd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. $StartCopyButton.Add_Click({
  2. $script:CancelLoop = $false
  3. $CancelButton.Enabled = $true
  4. $StartCopyButton.Enabled = $false
  5.  
  6. Get-ChildItem -LiteralPath $Source -Recurse -File | ForEach {
  7. Copy-Item -Path $.FullName -Destination $NewDestination
  8. [System.Windows.Forms.Application]::DoEvents()
  9. If($script:CancelLoop -eq $true) {
  10. #Exit the loop
  11. Break;
  12. }
  13. }
  14. $CancelButton.Enabled = $false
  15. $StartCopyButton.Enabled = $true
  16. })
  17.  
  18. $CancelButton.Add_Click({
  19. $script:CancelLoop = $true
  20. })
Add Comment
Please, Sign In to add comment