Monday, December 6, 2010

VBS Script Tutorial


To enable system administrators to work more efficiently without worrying about mundane and repetitive tasks, Microsoft created Visual Basic Script, or VBScript. This simple language allows the administrator to write a program that performs tasks automatically with no more than a single mouse click. As an example, this tutorial will describe how to create a Visual Basic script that will empty your Downloads folder for you.

Instructions

  1. Open a text editor. Any text editor will do, including the humble Windows Notepad. However, you may prefer an application like GVim that has built in-features for VBScript programming.

  2. Paste the following script into the text editor:



    Set FSO = CreateObject("Scripting.FileSystemObject");

    path = "C:\Users\Kevin\Downloads"



    for each file in FSO.GetFolder(path).Files

    file.delete

    Next



    Change the "Kevin" to your own username.

  3. Save the file to your desktop with the name "Empty Downloads.vbs."

  4. Double-click the file on your desktop any time you wish to empty your Downloads folder to save space. Use this with caution, however, since no confirmation is provided




No comments:

Post a Comment