Editor's note:
While this question is specifically about copying a file reference to the clipboard, its generic title led to answers about how to copy / get text.
As an Emacs user on Windows who often attaches files in mails, I have been looking for a utility to copy a file (not its contents) to the clipboard, just as windows explorer does on righclick/copy).
I just found this right here on SO which uses System.Windows.Forms.Clipboard` in a small program to do exactly that. But it is in C#, for which I don't have immediate access to a compiler. So I am wondering if this can be done and how.
I saw several references such as this that the clipboard is not accessible in VBScripting, but msdn shows documentation for VB so I am risking the question.
I have never written a VBScript before but I did try a few things before asking, starting with running a copy pasted a "Hello world" and then various combinations of CreateObject
etc.
Update: I need to call Clipboard.SetFileDropList
, so I do not think I can use ClipboardData
as suggested by the answers, it does not have this method.
Update for visitors
The solution I ended up using was to compile the C#
itself, I did not know I already had a compiler.
Another update for visitors https://stackoverflow.com/a/29963268/18573 is what I am now using, quite happily.