Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

PSHELL changes directory

May
12,998
174
When there is no persistent PowerShell interpreter PSHELL changes the current working directory to %SYSTEMROOT\System32. It does not do this if a persistent PowerShell interpreter is running,

Code:
v:\> pshell /c

v:\> pshell /s "echo foo"
foo

c:\windows\system32> v:

v:\> pshell /s "echo foo"
foo

v:\>
 
There's an alias for that;
Code:
e:\utils>which pshell
pshell is an alias : *pshell %@pshell[set-location '%_cwd']

Joe
 
There's an alias for that;
Code:
e:\utils>which pshell
pshell is an alias : *pshell %@pshell[set-location '%_cwd']

Joe
That doesn't seem to work if there's no persistent PowerShell interpreter running. And if there is a PowerShell interpreter running, there is no problem.

Code:
v:\> which pshell
pshell is an alias : *pshell %@pshell[set-location '%_cwd']

v:\> pshell /c

v:\> pshell /s "echo foo"
foo

c:\windows\system32>

This one works.

Code:
alias pshell `set ocwd=%_cwds & *pshell %$ & %ocwd & unset /q ocwd`
 
Here's another.

Code:
v:\> which pshell
pshell is an alias : setlocal & *pshell %$ & endlocal

v:\> pshell /c

v:\> pshell /s "echo foo"
foo

v:\> [code]

But I don't think an alias should be needed ... eh?
 

Similar threads

Back
Top