tags:

views:

4692

answers:

3

The VB trick to get the path of the current temporary directory:

Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

fails in VBScript. So?

+9  A: 
WScript.CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2)

It took me a while to find it on Google. So for the next one looking for the same as me...

Fabien
+5  A: 
Const WindowsFolder = 0

Const SystemFolder = 1

Const TemporaryFolder = 2

Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")

Dim tempFolder: tempFolder = fso.GetSpecialFolder(TemporaryFolder)
AnthonyWJones
Fabien's answer was correct as is this one, however, good documentation makes it easier for someone else to read.
Dscoduc
+5  A: 

Another possibility:

CreateObject("WScript.Shell").ExpandEnvironmentStrings("%Temp%")
Remou
Thanks, Patrick, I missed pasting a line, but that is better.
Remou
No problem. I was just about to paste my own, almost identical answer, when I saw you beat me by a second...again ;)
Patrick Cuff