Solved

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

Posted on 2006-06-22
7
495 Views
Last Modified: 2013-11-13
HI,

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

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

Thanks,

chris Schene
0
Comment
Question by:Christopher Schene
  • 4
  • 2
7 Comments
 
LVL 85

Expert Comment

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

Expert Comment

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

Author Comment

by:Christopher Schene
ID: 16964360
The user's temp folder...VB 6.0
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 275 total points
ID: 16964377
One way...

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

Assisted Solution

by:TiwariVikas
TiwariVikas earned 75 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
0
 
LVL 85

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)
0
 

Author Comment

by:Christopher Schene
ID: 16975003
Thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

840 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