G2A Many GEOs
SHARE
TWEET

POWERSHELL | LAB3ZAD2

bazmikel Apr 7th, 2020 315 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $Window = New-Object System.Windows.Forms.Form
  2. $Window.Text = "Laboratorium 3.2"
  3. $Window.Height = 640
  4. $Window.Width = 480
  5.  
  6. $DestinationsFile = New-Object System.Windows.Forms.FolderBrowserDialog
  7.  
  8. $komunikat = New-Object System.Windows.Forms.Label
  9. $komunikat.Text = ""
  10. $komunikat.Width = 200
  11. $komunikat.Location = New-Object System.Drawing.Size(190, 250)
  12.  
  13.  
  14. $textOne = New-Object System.Windows.Forms.Label
  15. $textOne.Location = New-Object System.Drawing.Size(140, 154)
  16. $textOne.Text =  "Wybierz lokalizacje: "
  17. $textOne.Width = 105
  18.  
  19. $textTwo = New-Object System.Windows.Forms.Label
  20. $textTwo.Location = New-Object System.Drawing.Size(140, 180)
  21. $textTwo.Text =  "Wprowadz nazwe dla nowego foldera: "
  22. $textTwo.Width = 200
  23.  
  24. $FoldersNameTextBox = New-Object System.Windows.Forms.TextBox
  25. $FoldersNameTextBox.Width = 170
  26. $FoldersNameTextBox.Text = ""
  27. $FoldersNameTextBox.Location = New-Object System.Drawing.Size(147, 197)
  28.  
  29.  
  30. $SelectButton = New-Object System.Windows.Forms.Button
  31. $SelectButton.Text = "Wybierz.. "
  32. $SelectButton.Location = New-Object System.Drawing.Size(250, 150)
  33. $SelectButton.Add_Click({
  34. $DestinationsFile.ShowDialog()
  35. })
  36.  
  37.  
  38. $CreateButton = New-Object System.Windows.Forms.Button
  39. $CreateButton.Text = "Utworz.. "
  40. $CreateButton.Location = New-Object System.Drawing.Size(197, 222)
  41. $CreateButton.Add_Click({
  42.     CheckAndAdd  
  43. })
  44.  
  45.  
  46.     function CheckAndAdd()
  47. {
  48.     cd $DestinationsFile.SelectedPath
  49.     Try
  50.     {
  51.         if(Test-Path -Path $FoldersNameTextBox.Text){
  52.         $komunikat.ForeColor = "Red"
  53.         $komunikat.Text = "Folder o podanej nazwie juz istnieje!"
  54.         }
  55.         else{
  56.             New-Item -Path $DestinationsFile.SelectedPath -ItemType "directory" -Name $FoldersNameTextBox.Text
  57.             $komunikat.ForeColor = "Green"
  58.             $komunikat.Text = "Folder utworzono!"
  59.         }
  60.    
  61.    
  62.     }
  63.     catch{
  64.             $komunikat.ForeColor = "Red"
  65.             $komunikat.Text = "Nie wprowadzono nazwy foldera!"
  66.    
  67.     }
  68.  
  69.  
  70.  
  71. }
  72.    
  73.    
  74.    
  75.  
  76.  
  77.  
  78.  
  79. #New-Item -Path $DestinationsFile.SelectedPath -ItemType "directory" -Name $FoldersNameTextBox.Text}
  80. #$komunikat.ForeColor = "Red"
  81.    # $komunikat.Text = "Nie wprowadzono nazwy foldera!"
  82. $Window.Controls.Add($komunikat)
  83. $Window.Controls.Add($CreateButton)
  84. $Window.Controls.Add($FoldersNameTextBox)
  85. $Window.Controls.Add($textTwo)
  86. $Window.Controls.Add($textOne)
  87. $Window.Controls.Add($SelectButton)
  88. $Window.ShowDialog()
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
Top