||The FileSystemObject provides a function - |
GetSpecialFolder - that can be used to retrieve the path of the folder Windows has designated as the temporary folder.
GetSpecialFolder can also be used to get the Windows folder name and the System folder name (usually
C:\WINNT\System32, respectively). The
GetSpecialFolder function has the following definition:
folderspec determines what special folder is returned:
0 - The Windows Folder is returned
1 - The System folder is returned
2 - The Temporary folder is returned
GetSpecialFolder function returns a Folder object, which contains a number of properties. To simply get the path to the temporary folder, we will use the
GetSpecialFolder to return a folder object, and then use the
Path property of the Folder object to return the path of the temporary folder.
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'This will return the path to the temporary folder
Set objFSO = Nothing
Pretty simple, eh? The FileSystemObject also provides a method to generate a temporary file name, in case you need to quickly create a temporary file. This method is
GetTempName. To learn more about it, be sure to read the technical docs.
An article on 4Guys - A Quick and Dirty Random Password Generator - demonstrates how to use the
GetTempName to create a seemingly random password. Definitely worth a read! Also be sure to check out these technical docs:
GetSpecialFolder technical docs
Folder object properties