You can drag files onto a WSH script. The file names are translated into arguments on the command line. These file names can be displayed in a list, which you can use to manipulate files with any scripting object.


To display a script's argument list

  1. Create a file and give it a name with a script extension (for example, DragDrop.vbs).

  2. Add code to the script file, for example:

    CopyCode imageCopy Code
    Set objArgs = WScript.Arguments
    For I = 0 to objArgs.Count - 1
       WScript.Echo objArgs(I)
  3. Save the file to your hard disk.

  4. Drag and drop any file or files onto your saved file. In the example, the file names are echoed back to the screen.

The number of files you can drag onto a script is limited by your system's maximum command-line length. If the total number of characters in all file names being dragged exceeds this limit, the drag and drop operation fails.