Created
April 14, 2016 00:24
-
-
Save jewel-andraia/13b9fe7ea7f3405c04d338f93b399ff8 to your computer and use it in GitHub Desktop.
Copy image to clipboard using PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Reflection.Assembly]::LoadWithPartialName('System.Drawing'); | |
[Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); | |
$filename = 'C:\Users\Administrator\Pictures\background-logo-1024.png'; | |
$file = get-item($filename); | |
$img = [System.Drawing.Image]::Fromfile($file); | |
[System.Windows.Forms.Clipboard]::SetImage($img); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FromFile method keeps $file locked until it's released from memory. Add the below line to the end of the script, if necessary to release the file.
$img.Dispose()