120 lines
4.7 KiB
PowerShell
120 lines
4.7 KiB
PowerShell
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
|
|
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
|
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
|
|
|
|
$folder = $null
|
|
|
|
Function Select-FolderDialog
|
|
{
|
|
param([string]$Description="Select Folder",[string]$RootFolder="Desktop")
|
|
|
|
$objForm = New-Object System.Windows.Forms.FolderBrowserDialog
|
|
$objForm.Rootfolder = $RootFolder
|
|
$objForm.Description = $Description
|
|
$Show = $objForm.ShowDialog()
|
|
If ($Show -eq "OK")
|
|
{
|
|
Return $objForm.SelectedPath
|
|
}
|
|
Else
|
|
{
|
|
Write-Error "Operation cancelled by user."
|
|
}
|
|
}
|
|
|
|
# the variable contains user folder selection
|
|
$folder = Select-FolderDialog -Description "Bitte Pfad angeben!"
|
|
|
|
IF ($folder -eq $Null) {
|
|
|
|
[System.Windows.Forms.MessageBox]::Show("Vorgang abgerochen. Programm/Script wird geschlossen.")
|
|
exit
|
|
|
|
} #end if
|
|
|
|
ELSE {
|
|
|
|
Get-ItemProperty -Path $folder | Format-list -Property * -Force
|
|
New-Item -Path $folder -Name Desktop.ini -Itemtype "File" -Force
|
|
|
|
$text1 = [Microsoft.VisualBasic.Interaction]::InputBox("Wenn der Ordner im Windows Explorer mit abweichendem Namen angezeigt werden soll, bitte diese Eingabe tätigen!", "Angezeigter Name (LocalizedResourceName)")
|
|
$text2 = [Microsoft.VisualBasic.Interaction]::InputBox("Wenn beim Mouse-Over über diesen Ordner ein Text erscheien soll, bitte diese Eingabe nun tätigen!", "Infotext zu diesem Ordner - (InfoTip)")
|
|
$text3 = [Microsoft.VisualBasic.Interaction]::InputBox("Bitte geben Sie Titel ein!", "Titel")
|
|
$text4 = [Microsoft.VisualBasic.Interaction]::InputBox("Bitte geben Sie Betreff ein!", "Subject")
|
|
$text5 = [Microsoft.VisualBasic.Interaction]::InputBox("Bitte geben Sie Autor ein!", "Author")
|
|
#$text6 = [Microsoft.VisualBasic.Interaction]::InputBox("Bitte geben Sie Markierungen ein!", "Tags")
|
|
|
|
# Set the size of your form
|
|
$Form = New-Object System.Windows.Forms.Form
|
|
$Form.width = 500
|
|
$Form.height = 300
|
|
$Form.Text = ”Bitte wählen Sie die Markierungen ein! (Tags)”
|
|
|
|
# Set the font of the text to be used within the form
|
|
$Font = New-Object System.Drawing.Font("Times New Roman",12)
|
|
$Form.Font = $Font
|
|
|
|
# create checkbox1
|
|
$checkbox1 = new-object System.Windows.Forms.checkbox
|
|
$checkbox1.Location = new-object System.Drawing.Size(30,30)
|
|
$checkbox1.Size = new-object System.Drawing.Size(250,50)
|
|
$checkbox1.Text = "Enable/Disable OK button"
|
|
$checkbox1.Checked = $true
|
|
$checkbox1.AutoSize
|
|
$Form.Controls.Add($checkbox1)
|
|
|
|
# create checkbox2
|
|
$checkbox2 = new-object System.Windows.Forms.checkbox
|
|
$checkbox2.Location = new-object System.Drawing.Size(30,60)
|
|
$checkbox2.Size = new-object System.Drawing.Size(250,50)
|
|
$checkbox2.Text = "Enable/Disable OK button"
|
|
$checkbox2.Checked = $true
|
|
$Form.Controls.Add($checkbox2)
|
|
|
|
# Add an OK button
|
|
$OKButton = new-object System.Windows.Forms.Button
|
|
$OKButton.Location = new-object System.Drawing.Size(130,100)
|
|
$OKButton.Size = new-object System.Drawing.Size(100,40)
|
|
$OKButton.Text = "OK"
|
|
$OKButton.Add_Click({$Form.Close()})
|
|
$form.Controls.Add($OKButton)
|
|
|
|
#Add a cancel button
|
|
$CancelButton = new-object System.Windows.Forms.Button
|
|
$CancelButton.Location = new-object System.Drawing.Size(255,100)
|
|
$CancelButton.Size = new-object System.Drawing.Size(100,40)
|
|
$CancelButton.Text = "Cancel"
|
|
$CancelButton.Add_Click({$Form.Close()})
|
|
$form.Controls.Add($CancelButton)
|
|
|
|
########### This is the important piece ##############
|
|
# #
|
|
# Do something when the state of the checkbox changes #
|
|
#######################################################
|
|
$checkbox1.Add_CheckStateChanged({
|
|
$OKButton.Enabled = $checkbox1.Checked })
|
|
|
|
|
|
# Activate the form
|
|
$Form.Add_Shown({$Form.Activate()})
|
|
[void] $Form.ShowDialog()
|
|
|
|
|
|
$text7 = [Microsoft.VisualBasic.Interaction]::InputBox("Bitte geben Sie Kommentar ein!", "Comment")
|
|
|
|
Add-Content $folder\Desktop.ini -Value "[.ShellClassInfo]"
|
|
Add-Content $folder\Desktop.ini -Value "LocalizedResourceName=$text1"
|
|
Add-Content $folder\Desktop.ini -Value "InfoTip=$text2"
|
|
Add-Content $folder\Desktop.ini -Value "[{F29F85E0-4FF9-1068-AB91-08002B27B3D9}]"
|
|
Add-Content $folder\Desktop.ini -Value "Prop2=31,$text3"
|
|
Add-Content $folder\Desktop.ini -Value "Prop3=31,$text4"
|
|
Add-Content $folder\Desktop.ini -Value "Prop4=31,$text5"
|
|
Add-Content $folder\Desktop.ini -Value "Prop5=31,$text6"
|
|
Add-Content $folder\Desktop.ini -Value "Prop6=31,$text7"
|
|
|
|
attrib +h +s $folder\Desktop.ini
|
|
attrib +r $folder
|
|
|
|
} #end else
|
|
|
|
exit |