Name

FileSystemObject.GetSpecialFolder Method

Syntax

                  oFileSysObj
                  .GetSpecialFolder(SpecialFolder)
oFileSysObj

Use: Required

Data Subtype: FileSystemObject object

Any object variable returning a FileSystemObject object.

SpecialFolder

Use: Required

Data Subtype: Special folder constant

A value specifying one of three special system folders.

Return Value

A Folder object.

Description

Returns a reference to a Folder object of one of the three special system folders: System, Temporary, and Windows.

Rules at a Glance

SpecialFolder can be one of the following special folder constants:

Constant

Value

Description

SystemFolder

1

The Windows system folder (/windows/system or /windows/system32)

TemporaryFolder

2

The folder that stores temporary files (../windows/temp)

WindowsFolder

0

The root folder of the Windows system folder tree (/windows or /winnt)

Programming Tips & Gotchas

  • As the previous table shows, the Scripting Runtime type library defines constants of the SpecialFolderConst enumeration that can be used in place of their numeric equivalents. You can use them in your scripts in either of two ways. You can define the constants yourself by adding the following code to your script:

    Const WindowsFolder = 0
    Const SystemFolder = 1
    Const TemporaryFolder = 2

    You can also include a METADATA tag in an ASP global.asa file or include the following line in a Windows Script Host (.wsf ) file in order to access the constants from the Scripting Runtime type library:

    <reference GUID="{420B2830-E718-11CF-893D-00A0C9054228}" ...

Get VBScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.