Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Whenever I run PowerShell as administrator, it starts in C:\WINDOWS\system32\WindowsPowerShell\v1.0. How do I make it start in my user's home directory instead? My $HOME has the expected value, i.e., C:\Users\<account>. Whenever I run PowerShell without administrative privileges it starts up in $HOME.

share|improve this question
    
Do you only want this to take effect when you open the PS CLI, or system-wide (ie: when scripts are run, etc.)? –  Ƭᴇcʜιᴇ007 Nov 14 '11 at 14:55
    
@techie007 When I open the CLI. Hadn't actually considered the script case. –  aknuds1 Nov 14 '11 at 15:06

1 Answer 1

up vote 3 down vote accepted

If you always use a shortcut you can just add the arguments:

-NoExit -Command "cd ~"

If you want this to always execute you can make a profile, to do this create the file (and missing folders on the path):

%userprofile%\Documents\WindowsPowerShell\profile.ps1

And place the cd command (cd ~) inside it.

To allow the scripts execution on startup you need to change the execution policy to be less restrictive, run powershell as admin and execute:

Set-Executionpolicy RemoteSigned

Do this at your own risk of course. If you did you will always end up in your home folder on startup.

share|improve this answer
    
Do you know why PowerShell defaults to another directory (than $HOME) when run with administrative privileges? Also, can I prevent "cd ~" from echoing the directory? –  aknuds1 Nov 15 '11 at 13:25
    
@aknuds1: I do not know why it starts there, possibly because the system files is where the admin most likely wants to do something. What do you mean by "echoing the directory", cd should not create any output. –  H.B. Nov 15 '11 at 16:15
    
Actually, for me, cd echoes the directory. I've tested by putting echo statements before and after the cd command in profile.ps1, and have that way verified this behaviour. –  aknuds1 Nov 15 '11 at 19:49
    
Interesting, wonder why it's different... –  H.B. Nov 15 '11 at 21:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.