VBScript Basics, Part 17 | Special Folders


VBScripting (.vbs) Basic tutorial on how to create and use special folders. The great thing about using these is that you can use them on multiple computers without having to worry about using the correct username or path.

Code Example:
______________________________________________________

Option Explicit
Dim fso, obj, nDirS, nDirD

Set fso = CreateObject(“Scripting.FileSystemObject”)
Set obj = CreateObject(“wscript.shell”)
nDirS = obj.SpecialFolders(“Startup”)
nDirD = obj.SpecialFolders(“Desktop”)

fso.CopyFile nDirD & “Little Moment.mp3” , nDirS & “”

msgbox “complete”
______________________________________________________

Know the Basics:
——————————————————————————————
CreateObject(“WScript.Shell”).SpecialFolders(“FOLDERNAME”)
——————————————————————————————
Set x = CreateObject(“WScript.Shell”)
x.SpecialFolders(“FOLDERNAME”)
——————————————————————————————

List of Special Folders:
——————————————————————————————
AllUsersDesktop
AllUsersStartMenu
AllUsersPrograms
AllUsersStartup
Desktop
Favorites
Fonts
MyDocuments
NetHood
PrintHood
Programs
Recent
SendTo
StartMenu
Startup
Templates



Leave a Comment