简体   繁体   中英

Powershell takes too long to close; can't totally override the default prompt function

I don't know what's happening with my Powershell. I have a shell registry key that allows me to open a Powershell window in a directory. The content is:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -NoExit 

And this is my custom defined prompt function:

function prompt {
    Write-Host ("on ") -NoNewLine -ForegroundColor White
    Write-Host ("$env:COMPUTERNAME") -NoNewLine -ForegroundColor Gray
    Write-Host (" in ") -NoNewLine -ForegroundColor White
    Write-Host ($(Get-Location)) -ForegroundColor Gray
    Write-Host ("$") -NoNewLine -ForegroundColor Magenta

    return "> ";
}

It should return something like

on PC-NAME in C:\\

$>

However, it returns this:

on PC-NAME in C:\\

$> PS C:>

Anything wrong at all with my Powershell? How do I get more debug information to help you guys?

I could fix this issue by commenting out a few functions in the PSReadline module that was installed. The module would add a `b to the end of the current prompt, append the user prompt to it, and would restore the default prompt when Powershell was being closed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM