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

Full Path of Windows Temp folder

Posted on 2011-03-08
Last Modified: 2012-05-11
How to get windows temp folder without truncation of folder name?
All solutions give C:\Docume~1\....
whereas I want it as C:\Documents and Settings\...

Removed the "TCP / IP" Zone, as it has nothing to do with the Q.

EE ZA Storage

Open in new window

Question by:Allan_Fernandes
LVL 26

Expert Comment

by:Dr. Klahn
ID: 35068520
This can be found in the registry key:


It is of type REG_EXPAND_SZ.

Expert Comment

ID: 35068540
Or %TEMP% is usually environment variable..
LVL 37

Expert Comment

by:Neil Russell
ID: 35068835
%TEMP% and %TMP% both give windows short names and NOT the full path as requested.
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

LVL 37

Expert Comment

by:Neil Russell
ID: 35068855
Here is an example of how to do it via VB6. you should be able to adapt the info on using the Kernel32 API's
LVL 37

Expert Comment

by:Neil Russell
ID: 35068859
LVL 37

Expert Comment

by:Neil Russell
ID: 35068878
It will NORMALLY be %USERPROFILE%\Local Settings\Temp

you can do that in a cmd prompt to expand

c:\> ECHO %USERPROFILE%\Local Settings\Temp

Accepted Solution

Allan_Fernandes earned 0 total points
ID: 35079314
Somehow GetLongPathName (delphi 5 and 2007) is not giving results, did not dig-in.
Managed to get a simple code that delivers across all versions.

Function LongFileName(ShortName: String): String;
// Usage: LongFileName('c:\DOCUME~1\User\LOCALS~1\Temp')
// Parameter=ShortName : Can be a filename or Foldername
// Returns '' if invalid input.
  SR: TSearchRec;
  Result := '';
  if not (DirectoryExists(ShortName) or FileExists(ShortName)) then
     exit ;
  If (pos('*',ShortName)+pos('?',ShortName) <> 0) Then
  Begin    { ignore joker chars }
  While FindFirst(ShortName, faAnyFile, SR) = 0 Do
    { next part as prefix }
    Result := '\' + SR.Name + Result;
    SysUtils.FindClose(SR);  { the SysUtils, not the WinProcs procedure! }
    { directory up (cut before '\') }
    ShortName := ExtractFileDir (ShortName);
    If length (ShortName) <= 2 Then
      Break;  { ShortName contains drive letter followed by ':' }
  Result := ExtractFileDrive (ShortName) + Result;

Original code: http://www.delphi3000.com/articles/article_1304.asp?SK=

Author Closing Comment

ID: 35120749

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Process prvSGxBA.exe 100 % CPU, is this a virus? 7 72
Blocking of USB Port 18 109
Backup Windows XP system 9 137
different catridges 8 100
Most of the time we are in fix when all of sudden our systems behave weirdly.  Such problems cost time and effort... so it's best to take some preventive actions so that we can avoid such issues or overcome such problems more easily. Preventive M…
Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

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