8
0
Skriptentwickung/test/Messageboxen mit Eingabeaufforderung und Icons.ps1
2024-01-24 16:42:38 +01:00

49 lines
2.4 KiB
PowerShell
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#Variante 1
$Result = [System.Windows.Forms.MessageBox]::Show("Möchten Sie das Script fortführen?","Frage an den Benutzer",1)
If ($Result -eq "Yes")
{
# Script läuft weiter.
}
else
{
# keine Aktion ausführen
}
#Variante 2
$Result = [System.Windows.Forms.MessageBox]::Show("Möchten Sie den Bildschirm sperren?","Frage an den Benutzer",4,[System.Windows.Forms.MessageBoxIcon]::Exclamation)
If ($Result -eq "Yes")
{
rundll32.exe user32.dll,LockWorkStation
}
else
{
# keine Aktion ausführen
}
#Ausgabe
#Bei 'JA' wird der Computer gesperrt. Alternative Tastenkombination
#ist [Win] + L
#Variante 3
$Result = [System.Windows.Forms.MessageBox]::Show("Möchten Sie die Datei überschreiben?","Frage an den Benutzer",3,[System.Windows.Forms.MessageBoxIcon]::Exclamation)
If ($Result -eq "Yes")
{
$a = "Schreibvorgang wurde fortgesetzt"
$a
}
elseif ($Result -eq "No")
{
$a = "Schreibvorgang wurde abgebrochen. Antwort Nein."
$a
}
else
{
$a = "Schreibvorgang wurde abgebrochen"
$a
}
#Ausgabe
#Ja = "Schreibvorgang wurde fortgesetzt"
#Nein = "Schreibvorgang wurde abgebrochen. Antwort Nein."
#Abbrechen = "Schreibvorgang wurde abgebrochen"