Advertisement
Guest User

powershellLP

a guest
Aug 26th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. Function Get-FileName
  2. {
  3. param (
  4. [Parameter(Mandatory=$True)] [String]$Dateien = "*"
  5. )
  6. [System.Reflection.Assembly]::LoadWithPartialName(“System.windows.forms”) |
  7. Out-Null
  8.  
  9. $EingabeFenster = New-Object System.Windows.Forms.OpenFileDialog
  10. $EingabeFenster.initialDirectory = "C:"
  11. $EingabeFenster.filter = “All files (*.$Dateien)| *.$Dateien”
  12. $EingabeFenster.ShowDialog() | Out-Null
  13. $EingabeFenster.filename
  14. }
  15.  
  16. Function Set-Wallpaper([string]$pfad)
  17. {
  18. Remove-ItemProperty -path "HKCU:\Control Panel\Desktop" -name WallPaper
  19. set-itemproperty -path "HKCU:Control Panel\Desktop" -name WallPaper -value $pfad
  20. Sleep -seconds 5
  21. RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True
  22. }
  23.  
  24. Function Get-Wallpaperpath
  25. {
  26. $Bildpfad = Get-FileName($Dateien = "bmp")
  27.  
  28. Set-WallPaper -value "$Bildpfad"
  29. }
  30.  
  31. Function Get-Prompthash
  32. {
  33. $Hashpfad = Get-FileName($Dateien = "*")
  34. $Test = Get-FileHash -Path "$Hashpfad"
  35. Write-Host $Test.hash
  36. }
  37.  
  38. Function Get-Processname
  39. {
  40. $sortfile = Get-FileName($Dateien = "*")
  41. $newfile = $sortfile.split(".")[-1]
  42. $filename = $sortfile.split("\")[-1]
  43. $pathname = $sortfile.replace($filename,"")
  44.  
  45.  
  46.  
  47. cd $pathname
  48. new-item -Path $pathname -name "Aufgeräumte $newfile" -ItemType "directory" -Force
  49. move-item "*.$newfile" -Destination "Aufgeräumte $newfile"
  50. }
  51.  
  52. function GenerateForm {
  53. [reflection.assembly]::loadwithpartialname(“System.Windows.Forms”) | Out-Null
  54. [reflection.assembly]::loadwithpartialname(“System.Drawing”) | Out-Null
  55. $MainForm = New-Object System.Windows.Forms.Form
  56. $Button1 = New-Object System.Windows.Forms.Button
  57. $Button2 = New-Object System.Windows.Forms.Button
  58. $Button3 = New-Object System.Windows.Forms.Button
  59. $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
  60.  
  61. $handler_Button1_Click=
  62. {
  63. Get-Wallpaperpath
  64. }
  65.  
  66. $handler_Button2_Click=
  67. {
  68. Get-Prompthash
  69. }
  70.  
  71. $handler_Button3_Click=
  72. {
  73. Get-Processname
  74. }
  75.  
  76. $OnLoadForm_StateCorrection=
  77. {
  78. $MainForm.WindowState = $InitialFormWindowState
  79. }
  80. $MainForm.Text = “Fenster”
  81. $MainForm.Name = “MainForm”
  82. $MainForm.DataBindings.DefaultDataSourceUpdateMode = 0
  83.  
  84. $System_Drawing_Size = New-Object System.Drawing.Size
  85. $System_Drawing_Size.Width = 165
  86. $System_Drawing_Size.Height = 125
  87. $MainForm.ClientSize = $System_Drawing_Size
  88. $Button1.TabIndex = 0
  89. $Button1.Name = “Button1”
  90. $Button2.TabIndex = 1
  91. $Button2.Name = "Button2"
  92. $Button2.TabIndex = 2
  93. $Button2.Name = "Button3"
  94.  
  95. $System_Drawing_Size = New-Object System.Drawing.Size
  96. $System_Drawing_Size.Width = 130
  97. $System_Drawing_Size.Height = 22
  98. $Button1.Size = $System_Drawing_Size
  99. $Button1.UseVisualStyleBackColor = $True
  100. $Button1.Text = “Hintergrund setzen”
  101.  
  102. $System_Drawing_Size = New-Object System.Drawing.Size
  103. $System_Drawing_Size.Width = 140
  104. $System_Drawing_Size.Height = 22
  105. $Button2.Size = $System_Drawing_Size
  106. $Button2.UseVisualStyleBackColor = $True
  107. $Button2.Text = “Hashwert berechnen”
  108.  
  109. $System_Drawing_Size = New-Object System.Drawing.Size
  110. $System_Drawing_Size.Width = 140
  111. $System_Drawing_Size.Height = 22
  112. $Button3.Size = $System_Drawing_Size
  113. $Button3.UseVisualStyleBackColor = $True
  114. $Button3.Text = “Aufräumen”
  115.  
  116. $System_Drawing_Point = New-Object System.Drawing.Point
  117. $System_Drawing_Point.X = 13
  118. $System_Drawing_Point.Y = 13
  119. $Button1.Location = $System_Drawing_Point
  120. $Button1.DataBindings.DefaultDataSourceUpdateMode = 0
  121. $Button1.add_Click($handler_Button1_Click)
  122.  
  123. $System_Drawing_Point = New-Object System.Drawing.Point
  124. $System_Drawing_Point.X = 13
  125. $System_Drawing_Point.Y = 53
  126. $Button2.Location = $System_Drawing_Point
  127. $Button2.DataBindings.DefaultDataSourceUpdateMode = 0
  128. $Button2.add_Click($handler_Button2_Click)
  129.  
  130. $System_Drawing_Point = New-Object System.Drawing.Point
  131. $System_Drawing_Point.X = 13
  132. $System_Drawing_Point.Y = 93
  133. $Button3.Location = $System_Drawing_Point
  134. $Button3.DataBindings.DefaultDataSourceUpdateMode = 0
  135. $Button3.add_Click($handler_Button3_Click)
  136.  
  137. $MainForm.Controls.Add($Button1)
  138. $MainForm.Controls.Add($Button2)
  139. $MainForm.Controls.Add($Button3)
  140. $InitialFormWindowState = $MainForm.WindowState
  141. $MainForm.add_Load($OnLoadForm_StateCorrection)
  142. $MainForm.ShowDialog()| Out-Null
  143. }
  144.  
  145. GenerateForm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement