# Import the necessary assemblies Add-Type -AssemblyName System.Windows.Forms # Create the form $form = New-Object System.Windows.Forms.Form $form.Text = "System Sounds" $form.Size = New-Object System.Drawing.Size(400,300) # Create the list box $listBox = New-Object System.Windows.Forms.ListBox $listBox.Location = New-Object System.Drawing.Size(10,10) $listBox.Size = New-Object System.Drawing.Size(375,250) $form.Controls.Add($listBox) # Get the system sounds directory $systemSoundsDir = [System.Environment]::GetFolderPath("Windows") + "\Media" # Populate the list box with the system sounds Get-ChildItem -Path $systemSoundsDir | ForEach-Object { $listBox.Items.Add($_.Name) } # Define the list box's selected index changed event $listBox.Add_SelectedIndexChanged({ # Get the selected sound file $selectedSound = $listBox.SelectedItem # Play the sound (New-Object System.Media.SoundPlayer -ArgumentList "$systemSoundsDir\$selectedSound").Play() }) # Show the form $form.ShowDialog()