SHARE
TWEET

Untitled

a guest Jul 17th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Add-Type -AssemblyName System.Windows.Forms
  2. $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
  3.     InitialDirectory = [Environment]::GetFolderPath('Desktop')
  4.     Multiselect = $true # Multiple files can be chosen
  5.  
  6. }
  7.  
  8. [void]$FileBrowser.ShowDialog()
  9.  
  10. $path = $FileBrowser.FileNames;
  11.  
  12. If($FileBrowser.FileNames -like "**") {
  13.  
  14.     # Do something before work on individual files commences
  15.     $FileBrowser.FileNames #Lists selected files (optional)
  16.  
  17.     foreach($file in Get-ChildItem $path){
  18.     Get-ChildItem ($file) |
  19.         ForEach-Object {
  20.             Set-ItemProperty -Path $path -Name IsReadOnly -Value $true
  21.             compact /C $_.FullName
  22.         }
  23.     }
  24.     # Do something when work on individual files is complete
  25. }
  26.  
  27. else {
  28.     Write-Host "Cancelled by user"
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top