Useful Tip: Copy message box text to clipboard

Yesterday I was working with two IT professionals who had probably over 25 years of combined experience working with Windows, but neither of them was aware of this useful technique.

It’s possible to copy the contents of a standard Windows message box into the clipboard. This is especially useful for those cases where a full exception and stack trace is included in the message.

Given this message box:
image

Pressing CTRL+C will place the following text in the Windows clipboard:image

In case you’re wondering how I generated that message box, it took two lines of PowerShell:

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.MessageBox]::Show("Message Box Text","Message Box Title",[Windows.Forms.MessageBoxButtons]::RetryCancel,[Windows.Forms.MessageBoxIcon]::Error)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s