O Windows Powershell está demorando muito para iniciar a primeira vez após o login do Windows

4

Geralmente, uso o windows powershell em vez do prompt de comando no Windows. Tenho notado que, quando eu inicio pela primeira vez depois que o Windows é iniciado, leva muito tempo para o prompt dos comandos aparecerem.

Para resolver esse problema, inicio e fecho-o imediatamente e, em seguida, inicio novamente. Se eu fizer isso, ele começará quase instantaneamente.

Existe uma maneira de garantir que o prompt de comando apareça imediatamente em vez de eu ter que fazer este pequeno hack?

    
por Aseem Bansal 02.08.2013 / 09:49

2 respostas

5

O PowerShell conta com o .NET Framework , você pode tentar atualizar naquela. Além disso, notei alguns problemas com o script na outra resposta

  • sort causará um erro porque nem todas as entradas têm location
  • alguns sistemas se beneficiarão de re ngen ing, o que esse script nunca fará

Aqui está minha versão modificada

$Env:PATH = [Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()
[AppDomain]::CurrentDomain.GetAssemblies() | % {
  $pt = $_.Location
  if (! $pt) {continue}
  if ($cn++) {''}
  $na = Split-Path -Leaf $pt
  Write-Host -ForegroundColor Yellow "NGENing $na"
  ngen install $pt
}
    
por 06.07.2014 / 21:02
1
Set-Alias ngen (Join-Path ([System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()) ngen.exe)
[AppDomain]::CurrentDomain.GetAssemblies() |
    sort {Split-path $_.location -leaf} |
    %{
        $Name = (Split-Path $_.location -leaf)
        if ([System.Runtime.InteropServices.RuntimeEnvironment]::FromGlobalAccessCache($_))
        {
            Write-Host "Already GACed: $Name"
        }else
        {
            Write-Host -ForegroundColor Yellow "NGENing      : $Name"
            ngen $_.location | %{"'t$_"}
         }
      }

Fonte --- Faça o download do código como arquivo ps1

If the workstation has no direct internet access unmark this option in IE: 'Check for publisher's certificate revocation' under advanced

You might want to double-check and verify there are no profiles. Run this command and see if any of these are true:

PS S:> $profile.CurrentUserAllHosts, $profile.CurrentUserCurrentHost, $profile.AllUsersAllHosts, $profile.AllUsersCurrentHost | test-path

Fonte

Citação levemente editada do original

The problem [could be due to] slow setting of user environment variables. I recently merged a change that uses a temp file instead.

Origem

Mais sobre o ambiente do usuário as variáveis podem ser encontradas aqui que também sugere que pode ser o Chrome nos comentários:

Apparently it's Google Chrome that's the culprit here. If I close Chrome, the operation completes in a couple of seconds. Wonder why Chrome lets those messages time out.
I guess this might require digging into Chrome code... Another idea is that Chrome application usually runs in dozens of processes, each tab and extension is in a separate one. Perhaps, the more tabs open/extensions you have, the more time it will take to process the system message.

Como a sua falha é demorar um pouco para carregar inicialmente (mas rápido depois), tente

...then you are seeing the time it takes to load .NET, PSH and Snapins. If not, then likely to be profile related (either PSH profile or something like contacting AD1).'

Source

    
por 02.08.2013 / 09:55