Solved

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

Posted on 2006-06-22
7
500 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
[X]
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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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?
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

728 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