Option Explicit Dim objIE ' Parse the command line arguments If WScript.Arguments.Count <> 1 Then Syntax If WScript.Arguments.Named.Count = 1 Then If WScript.Arguments.Named.Exists( "Register" ) Then Register ElseIf WScript.Arguments.Named.Exists( "Unregister" ) Then UnRegister Else Syntax End If End If ' If the command line argument is a text string, send it to the ' clipboard. The Internet Explorer object is used, because WSH ' and VBScript don't support clipboard access by themselves. If WScript.Arguments.UnNamed.Count = 1 Then Set objIE = CreateObject( "InternetExplorer.Application" ) objIE.Navigate( "about:blank" ) objIE.Document.ParentWindow.ClipboardData.SetData "text", _ WScript.Arguments.Unnamed(0) objIE.Quit Set objIE = Nothing End If Sub Register Dim wshShell Set wshShell = CreateObject( "WScript.Shell" ) On Error Resume Next ' Add the required registry entries for files wshShell.RegWrite "HKEY_CLASSES_ROOT\*\shell\sendclip\", _ "Send full path to clipboard" wshShell.RegWrite "HKEY_CLASSES_ROOT\*\shell\sendclip\command\", _ "wscript.exe """ & WScript.ScriptFullName _ & """ ""%L""", "REG_EXPAND_SZ" ' Add the required registry entries for folders wshShell.RegWrite "HKEY_CLASSES_ROOT\Folder\shell\sendclip\", _ "Send full path to clipboard" wshShell.RegWrite "HKEY_CLASSES_ROOT\Folder\shell\sendclip\command\", _ "wscript.exe """ & WScript.ScriptFullName _ & """ ""%L""", "REG_EXPAND_SZ" On Error Goto 0 Set wshShell = Nothing WScript.Quit 0 End Sub Sub UnRegister Dim wshShell Set wshShell = CreateObject( "WScript.Shell" ) On Error Resume Next ' Remove the registry entries for the files menu wshShell.RegDelete "HKEY_CLASSES_ROOT\*\shell\sendclip\command\" wshShell.RegDelete "HKEY_CLASSES_ROOT\*\shell\sendclip\" ' Remove the registry entries for the folders menu wshShell.RegDelete "HKEY_CLASSES_ROOT\Folder\shell\sendclip\command\" wshShell.RegDelete "HKEY_CLASSES_ROOT\Folder\shell\sendclip\" On Error Goto 0 Set wshShell = Nothing WScript.Quit 0 End Sub Sub Syntax Dim strMsg strMsg = "SendClip.vbs, Version 1.01" & vbCrLf _ & "Send a text string to the clipboard" & vbCrLf & vbCrLf _ & "Usage: WSCRIPT SENDCLIP.VBS ""text string"" " _ & "| /Register | /Unregister" & vbCrLf & vbCrLf _ & "Where: ""text string"" is the text to be sent to " _ & "the clipboard" & vbCrLf _ & " /Register Adds an entry " _ & """Send full path to clipboard""" & vbCrLf _ & " to Explorers' " _ & "context menu for all files" & vbCrLf _ & " /UnRegister Removes the menu entry again" _ & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" & vbCrLf _ & "http://www.robvanderwoude.com" WScript.Echo strMsg WScript.Quit 1 End Sub