Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8002341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:19:57+00:00 2026-06-04T16:19:57+00:00

In PowerShell I can echo the value of %TEMP% using the command $Env:TEMP .

  • 0

In PowerShell I can echo the value of %TEMP% using the command $Env:TEMP. Here is the output on my machine:

PS> $Env:temp
C:\Users\IAIN~1.COR\AppData\Local\Temp

When I try to change to the directory using the cd command, I receive this error:

PS> cd $Env:temp
Set-Location : An object at the specified path C:\Users\IAIN~1.COR does not exist.
At line:1 char:3
+ cd <<<<  $Env:temp
    + CategoryInfo          : InvalidArgument: (:) [Set-Location], PSArgumentException
    + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.SetLocationCommand

I suspect that PowerShell is interpreting the 8.3 file name literally. The long file name of the directory is C:\Users\iain.CORP\AppData\Local\Temp. When I try cd C:\Users\Iain.CORP\AppData\Local\Temp, the directory changes successfully.

How can I open the path in $Env:TEMP using PowerShell? Do I have to have the long file name first?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:19:58+00:00Added an answer on June 4, 2026 at 4:19 pm

    You don’t need to access the %TEMP% environment variable directly.

    .NET provides a GetTempPath method as a more general solution.

    $TempDir = [System.IO.Path]::GetTempPath()
    cd $TempDir
    

    On my machine, this changes to the directory C:\Users\Iain.CORP\AppData\Local\Temp.

    Remarks from the documentation:

    This method checks for the existence of environment variables in the
    following order and uses the first path found:

    1. The path specified by the TMP environment variable.

    2. The path specified by the TEMP environment variable.

    3. The path specified by the USERPROFILE environment variable.

    4. The Windows directory.

    Thanks to Joe Angley for sharing the technique.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PowerShell I can get the directories with the following command: Get-ChildItem -Path $path
I'm using powershell script to run a few *.sql file. I can get the
knowing what PowerShell can do on a command line I have never learned how
Can PowerShell on Windows by itself or using simple shell script, list files and
PowerShell can call commandline batch files. PowerShell script output can be recorded with the
I'm trying to read an rss feed using powershell and I can't extract a
It appears that I can escape command line arguments using single or double quotes:
I want to install the PowerShell Community Extensions using only the command-line. I don't
I can execute the following command in PowerShell: msbuild c:\some\spaced path\project.sln /p:MvcBuildViews=False /p:OutDir=c:\\some\\spaced path\\deploy\\Package\\
How can I save the results from a Powershell command to a MS SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.