Jump to content

%Temp% VS Temp


Recommended Posts

In a Windows OS, primarily Win XP environment

Using script " @WinDir" we can locate the "Temp" directory that is in for example: "c:\Windows\Temp"

This can also be found via a command / run line entry of " Temp in most cases it will be found then at "(Drive letter):\Windows\Temp"

However I wish for the script to locate and perform operations on the other Temp directory.

This one can normally be found via a command / run line entry of " %Temp% in some cases it will be found then at "(Drive Letter):\Documents and Settings\(username)\Local Settings\Temp

However it can be on located in different areas depending on system configuration

I can locate and do some deleting etc. by writing script that will use the command line, however that runs into more problems when files are in use etc.

It would be much nicer if there were a command to locate it easier. Such as in the examples of: "$path = @WindowsDir & '\Temp'"

or "$path = @AppData & '\Microsoft\Outlook'

So I am looking for a simple script line to point to the same location as the run line command "%Temp%"

Link to comment
Share on other sites

  • Replies 42
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

@TempDir

or

EnvGet("TEMP")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

@TempDir

or

EnvGet("TEMP")

I appreciate the help, however...

Unfortunately, in my tests, the aforementioned code points to the same directory as " @WindowsDir & '\Temp' "

Which is equal to using the command / run line entry of: Temp

That returns a path of: " I:\WINDOWS\Temp " On this system I am at right now.

I am looking to point to a different Temp folder. The one that would be found by: using the command / run line entry of:

" %Temp% "

On this system I am at right now that would return a path of: " I:\DOCUME~1\user\LOCALS~1\Temp " Which in long hand would equate to: " I:\Documents and Settings\user\Local Settings\Temp "

Perhaps I'm not using it coding it correctly.

Any other ideas?

Link to comment
Share on other sites

I'm not sure why that's happening to you.

On my system both methods point to

" C:\DOCUME~1\user\LOCALS~1\Temp "

as does Start >> Run >> %TEMP%

Must be something in the environment settings of that machine.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Try this:

MsgBox(0, EnvGet("TEMP"), @TempDir)

I get(swe winxp sp2)

---------------------------

C:\DOCUME~1\RKESKG~1\LOKALA~1\Temp

---------------------------

C:\DOCUME~1\RKESKG~1\LOKALA~1\Temp

---------------------------

You must be doing something else wrong if you get windows\temp
Link to comment
Share on other sites

As an afterthought try

EnvGet("%TMP%")

That is often not the same folder as %TEMP%

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

As an afterthought try

EnvGet("%TMP%")

That is often not the same folder as %TEMP%

Are you sure about that?? Here it goes to the same as the other two...

C:\DOCUME~1\RKESKG~1\LOKALA~1\Temp

C:\DOCUME~1\RKESKG~1\LOKALA~1\Temp

C:\DOCUME~1\RKESKG~1\LOKALA~1\Temp

Edited by AdmiralAlkex
Link to comment
Share on other sites

I'm running a fresh installation of XP Pro Sp2.

When I go to System Properties > Advanced > Environment variables I have:

User variables for username:

TEMP C:\Documents and Settings\username\Local Settings\Temp

TMP C:\Documents and Settings\username\Local Settings\Temp

System variables:

TEMP C:\Windows\Temp

TMP C:\Windows\Temp

%TEMP% = C:\Windows\Temp

@TempDir = C:\WINDOWS\TEMP

Link to comment
Share on other sites

Are you sure about that?? Here it goes to the same as the other two...

That is normal however the Windows Environment CAN point to a different folder for %TMP% and I have seen it that way. During a normal installation of Windows they will point to the same folder but another app could change one environment setting or the other.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

To reafirm in part. I'm afraid people think I am crazy (Ok, maybe I am but I don't want everyone to know it)

Depending on the system configuration and applications installed the two different temp files can be located in differet areas (paths)

So do we have a good easy way of putting in for the script to locate and then input into the appropriate line so we can have it take actions on the files in those different folders individually. Such as FileDelete, FileRecycle or other actions.

Please do not take this as condecending, I just want to simplify and be accurate. Try this scenario.

Take an XP system, with more then 1one user account. Have the OS installed on a drive other then C.

Have the My Documents folder (or other shell folders) changed to a different directory then what is automatically assigned by MSFT. Easily done with a small registry change.

click: <start>

click: <run>

enter: temp

click: <OK>

See what directory path you get

click: <start>

click: <run>

enter: %temp%

click: <OK>

See what directory path you get

I believe you will find them to be different.

Obviously I can point to it on a particular system. I am looking for thsi to function properly on many different systems when the %temp% & Temp directories might be allocated in unknown areas.

That is normal however the Windows Environment CAN point to a different folder for %TMP% and I have seen it that way. During a normal installation of Windows they will point to the same folder but another app could change one environment setting or the other.

Link to comment
Share on other sites

«Start - Run - Temp» will show you the "C:\Windows\Temp" directory because the "WorkingDir" for FileRun function (program?) is "C:\Windows" this is the first found dir in the PATH environment (see next posts), therefore you get executed the only found Temp directory in the current path (dir), wich is a Windows directory.

Just try instead of "Temp" writing "..\Temp", you will get executed "C:\Temp" directory (if you got this folder there :D).

But if you use the %Temp% environment, you get the correct path to the temporary directory defined by your system.

Conclusion: Use @TempDir macro and be happy :D

Edited by MsCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

I can't be happy if I cannot point to the correct directory.

@TempDir does not point to the correct directory.

That seems a bit like looking for something in the wrong location because the "light is better over there" It still wont help me find what I am looking for.

Anybody have any other suggestions?

"But if you use the %Temp% environment, you get the correct path to the temporary directory defined by your system."

Conclusion: Use @TempDir macro and be happy :D

Link to comment
Share on other sites

It still wont help me find what I am looking for

And what exactly are you looking for, what you expecting to be set in the %Temp% environment, or in @TempDir macro?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

click: <start>

click: <run>

enter: temp

click: <OK>

See what directory path you get

Please do not take this as condescending, the OS looks for a file/folder that matches using the order of the paths in the PATH settings. I'm not sure what the point of your test was/is.

start > run > Cursors > ok --- opens C:\WINDOWS\Cursors

start > run > Config > ok ---- opens C:\WINDOWS\system32\config

Even though there is a folder named C:\WINDOWS\Config...

...because C:\WINDOWS\system32 comes before C:\WINDOWS in my PATH settings.

For me:

start > run > temp > ok --- opens an error message

('cuz I have no folder named C:\WINDOWS\Temp)

Okay, let me create a folder named C:\WINDOWS\Temp

Okay - now I have that folder - your test

start > run > temp > ok --- opens a Windows Explorer view of that folder.

C:\WINDOWS\Temp is not found in my OS Env settings...

...so the test of...

start > run > temp > ok

...tells you very little.

So, I probably wasted all of that typing because you already knew all of that and I just did not understand what you wanted us to learn about our computer's settings via that test.

Now, back to AutoIt. You have posted some things (as have others in this thread) that don't make sense to me. [stop laughing]

@MsCreatoR

«Start - Run - Temp» will show you the "C:\Windows\Temp" directory because the "WorkingDir" for FileRun function (program?) is "C:\Windows", therefore ...

If that were the case, then

start > run > Config > ok should open C:\WINDOWS\Config

@weaponx

%TEMP% = C:\Windows\Temp

@TempDir = C:\WINDOWS\TEMP

That ain't normal - possible, but not normal. Care to run AdmiralAlkex's code
MsgBox(0, EnvGet("TEMP"), @TempDir)
and report back?

@keypuncher

I must summarize - cannot quote concisely:

EnvGet("TEMP") = "I:\WINDOWS\Temp"

start > run > %TEMP% > ok = "I:\DOCUME~1\user\LOCALS~1\Temp"

That is not supposed to happen... so let's keep working on this.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

What a research around Temp :D ...

If that were the case, then

start > run > Config > ok should open C:\WINDOWS\Config

Well, after reading your tests, i have to not agree with my self :D - Yes, it seems that the FileRun check first in the PATH, so probably there is something wrong in the "PATH" of @keypuncher.

P.S

I just trying to understand, what is the difference where the Temp directory will be kept, what is the purpose of all this?

Edited by MsCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

...P.S

I just trying to understand, what is the difference where the Temp directory will be kept, what is the purpose of all this?

I was attempting to show that start > run > temp > ok may be a red heiring to this discussion. It does not tell you much (if anything) about the OS Env settings. [but maybe the OP was not saying that it did tell you info about the OS Env settings - I just don't know.]

I want to know how this can happen:

EnvGet("TEMP") = "I:\WINDOWS\Temp"

start > run > %TEMP% > ok = "I:\DOCUME~1\user\LOCALS~1\Temp"

I have scripts that use EnvGet("TEMP").

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

I want to know how this can happen:

It's strange indeed, when i run this example:

Opt("ExpandEnvStrings", 1)

ConsoleWrite(EnvGet("Temp") & @LF & "%Temp%" & @LF & @TempDir)

I get all three results the same: C:\DOCUME~1\User\LOCALS~1\Temp

@keypuncher

What you get with this example?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...