Microsoft® Windows® Script Host Drag and Drop Support |
WSH Tutorial Previous Next |
The Windows operating system currently supports drag and drop with batch files. This functionality, which enables you to drag one or more files onto a batch file and then run it with the files as arguments, is now supported in Windows Script Host version 2.0 as well.When you 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
Set objArgs = WScript.Arguments For I = 0 to objArgs.Count - 1 WScript.Echo objArgs(I) Next
The number of files you can drag onto a script is limited by the maximum command-line length your system allows. If the total number of characters in all file names being dragged exceeds this limit, the dragging and dropping operation will fail.