Skip to content

Instantly share code, notes, and snippets.

Created Mar 22, 2012
What would you like to do?
PowerShell Drag & Drop sample
# PowerShell Drag & Drop sample
# Usage:
# powershell -sta -file dragdrop.ps1
# (-sta flag is required)
Function DragDropSample() {
$form = New-Object Windows.Forms.Form
$form.text = "Drag&Drop sample"
$listBox = New-Object Windows.Forms.ListBox
$listBox.Dock = [System.Windows.Forms.DockStyle]::Fill
$handler = {
if ($_.Data.GetDataPresent([Windows.Forms.DataFormats]::FileDrop)) {
foreach ($filename in $_.Data.GetData([Windows.Forms.DataFormats]::FileDrop)) {
$form.AllowDrop = $true
DragDropSample | Out-Null
Copy link

mjquito commented May 24, 2016


Copy link

kreynazpm commented Apr 2, 2020

When I try to run this script in VS Code, the console just spins and spins. Does this script depend on something else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment