Skip to content

Instantly share code, notes, and snippets.

@daanta-real
Created April 15, 2026 12:06
Show Gist options
  • Select an option

  • Save daanta-real/d7f5352a6fe70384a8831111698a1c99 to your computer and use it in GitHub Desktop.

Select an option

Save daanta-real/d7f5352a6fe70384a8831111698a1c99 to your computer and use it in GitHub Desktop.
The command to show an draggable image on the desktop in Windows
# The command to show an draggable image on the desktop in Windows.
# type: cmd
# replace "YOUR_IMAGE_PATH" to your image path.
powershell -sta -c "Add-Type -A System.Windows.Forms;$f=New-Object Windows.Forms.Form;$f.FormBorderStyle='None';$f.BackColor=$f.TransparencyKey=[Drawing.Color]::Magenta;$f.TopMost=1;$f.StartPosition='CenterScreen';$p=New-Object Windows.Forms.PictureBox;$p.Image=[Drawing.Image]::FromFile('YOUR_IMAGE_PATH');$p.SizeMode='AutoSize';$p.BackColor=[Drawing.Color]::Magenta;$d=$false;$ox=0;$oy=0;$p.Add_MouseDown({$script:d=$true;$script:ox=$_.X;$script:oy=$_.Y});$p.Add_MouseMove({if($script:d){$f.Left+=$_.X-$script:ox;$f.Top+=$_.Y-$script:oy}});$p.Add_MouseUp({$script:d=$false});$p.Add_DoubleClick({$f.Close()});$f.Controls.Add($p);$f.Size=$p.Image.Size;$f.ShowDialog()"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment