Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2006-06-22
7
Medium Priority
?
506 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 86

Expert Comment

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

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 86

Accepted Solution

by:
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
0
 
LVL 2

Assisted Solution

by:TiwariVikas
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
0
 
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)
0
 

Author Comment

by:Christopher Schene
ID: 16975003
Thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Loops Section Overview

581 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