Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


How do I access the "temp directory" environment variable in VB

Posted on 2006-06-22
Medium Priority
Last Modified: 2013-11-13

I need to get the location of the temp directory from a VB call.

How do I do that (api call, etc)?


chris Schene
Question by:Christopher Schene
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16964294
You want the Users temp folder?...or the Machines temp folder?
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16964297
Also what version VB are you working in?

Author Comment

by:Christopher Schene
ID: 16964360
The user's temp folder...VB 6.0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 86

Accepted Solution

Mike Tomlinson earned 1100 total points
ID: 16964377
One way...

    Private Sub Command1_Click()
        Dim UserTempFolder As String
        UserTempFolder = Environ("Temp")
        Debug.Print UserTempFolder
    End Sub

Assisted Solution

TiwariVikas earned 300 total points
ID: 16966765
Hi cshene ,

you can access any environment variable with following code:

Dim objShell as object
Dim strTemp as string
Set objShell = CreateObject("Wscript.Shell")
strTemp = objShell.ExpandEnvironmentStrings("%temp%")
msgbox strTemp
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16968797
Why use a late bound scripting object when the Environ() function does the same thing?...

Both examples produced the same output on my system.  (WinXP SP2)

Author Comment

by:Christopher Schene
ID: 16975003

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question