Use clipboard from VBScript

clipboard, vbscript, windows-xp

Solution

Microsoft doesn't give a way for VBScript to directly access the clipboard. If you do a search for `'clipboard'`on this site you'll see:

Although Visual Basic for Applications supports the Screen, Printer, App, Debug, Err, and Clipboard objects, VBScript supports only the Err object. Therefore, VBScript does not allow you to access such useful objects as the mouse pointer or the clipboard. You can, however, use the Err object to provide runtime error handling for your applications.

So using notepad indirectly is probably about the best you'll be able to do with just VBScript.

Problem

I am looking for a method to place some text onto the clipboard with VBScript. The VBScript in question will be deployed as part of our login script. I would like to avoid using anything that isn't available on a clean Windows XP system. Edit: In answer to the questions about what this is for. We wanted to encourage users inside our organization to use the file server to transfer documents instead of constantly sending attachments by email. One of the biggest barriers to this is that it isn't always obvious to people what the correct network path is to a file/folder. We developed a quick script, and attached it to the Windows context menu so that a user can right click on any file/folder, and get a URL that they can email to someone within our organization. I want the URL displayed in the dialog box to also be placed onto the clipboard. GetNetworkPath

Original source