Solved

Full Path of Windows Temp folder

Posted on 2011-03-08
8
1,307 Views
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.

rindi,
EE ZA Storage

Open in new window

0
Comment
Question by:Allan_Fernandes
[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
8 Comments
 
LVL 27

Expert Comment

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

HKEY_CURRENT_USER/Environment/TEMP

It is of type REG_EXPAND_SZ.
0
 
LVL 8

Expert Comment

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

Expert Comment

by:Neil Russell
ID: 35068835
%TEMP% and %TMP% both give windows short names and NOT the full path as requested.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 35068859
0
 
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
0
 

Accepted Solution

by:
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.
var
  SR: TSearchRec;
Begin
  Result := '';
  if not (DirectoryExists(ShortName) or FileExists(ShortName)) then
     exit ;
  If (pos('*',ShortName)+pos('?',ShortName) <> 0) Then
  Begin    { ignore joker chars }
    Exit;
  End;
  While FindFirst(ShortName, faAnyFile, SR) = 0 Do
  Begin
    { 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
    Begin
      Break;  { ShortName contains drive letter followed by ':' }
    End;
  End;
  Result := ExtractFileDrive (ShortName) + Result;
end;

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

Author Closing Comment

by:Allan_Fernandes
ID: 35120749
Thanks
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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