Today we are going to talk about special folders in VbScript. Special Folders tend to be hidden or require a specific username to get to them. The Special Folders Command in VbScript are pre-defined directory paths that can be useful when moving a file from one directory to another; or any task that requires you to use common directories on the computer.
Table of Contents
Special Folder Paths
To specify a special folder, you can use this base code:
Option Explicit Dim obj Set obj = createobject("wscript.shell") obj.specialfolders("")
Within the parenthesis-quotation of obj.specialfolder, you can specify the paths of any of these special folders:
----List of Special Folders ---- AllUsersDesktop AllUsersStartMenu AllUsersPrograms AllUsersStartup Desktop Favorite Fonts MyDocuments NetHood PrintHood Programs Recent SendTo StartMenu Startup Templates
***If you put a file in the AllUsersDesktop special folder, the file will show up for all the users on their desktops.
SpecialFolders are like preset paths or addresses to specific or “special” folders
For example, the Desktop special folder command gives you the preset path to the desktop folder.
Option Explicit Dim obj Set obj = createobject("wscript.shell") msgbox obj.specialfolders("Desktop")
Output:
Open Special Folders
Notice that if you want to open the folder on your desktop, in addition to the default code you need to tell the VbScript to add a dash at the end of “C:\Users\rock\Desktop”. Like so:
Option Explicit Dim obj Set obj = createobject("wscript.shell") obj.run obj.specialfolders("Desktop")& "\workshop"
=
Option Explicit Dim obj, path Set obj = createobject("wscript.shell") path = obj.specialfolders("Desktop")& "\workshop" obj.run path
Output:

Copying a file to a Special Folder
To Copy a file to the startup folder:
Option Explicit Dim fso, obj Set fso = CreateObject("Scripting.FileSystemObject") Set obj = CreateObject("wscript.shell") fso.CopyFile "C:\Users\rock\Desktop\BigEyeCat.jpg" , obj.SpecialFolders("Startup")& "\"
=
Option Explicit Dim fso, obj, nDirS Set fso = CreateObject("Scripting.FileSystemObject") Set obj = CreateObject("wscript.shell") nDirS = obj.SpecialFolders("Startup")& "\" fso.CopyFile "C:\Users\rock\Desktop\BigEyeCat.jpg" , nDirS
=
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& "\BigEyeCat.jpg" , nDirS & "\"
Output:

To summarize: instead of trying to find the full path or directory to a “special” Folder, you can use the Special Folder command to automatically specify the path.