Chocolatey not available after being installed through ScreenConnect



  • I installed Chocolatey via powershell in a CMD push from ScreenConnect. Install ended with no errors.

    But when trying to run Choco via CMD or PS withing SC, I get this error:

    choco : The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program. Check 
    the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At C:\Windows\TEMP\ScreenConnect\19.2.24707.7131\f5d4735e-308a-408b-ab46-1e7e110970c8run.ps1:1 char:1
    + choco install putty.install
    + ~~~~~
        + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    

    However, when running from a CMD or PS at the client console, all is fine.

    The installer warns that restarting the cmd or powershell may be needed before choco will work, but how would you do this via SC cmd when the SC cmds are run as system?



  • I have never had it be accessible to screen connect until a reboot. But I rarely install it this way, so memory is fuzzy.

    I guess you could cycle the screenconnect client service. That should do the same.



  • When you run this, $env:ChocolateyInstall, does it show C:\ProgramData\chocolatey
    Also try refreshenv command to see that helps.



  • @black3dynamite said in Chocolatey not available after being installed through ScreenConnect:

    refreshenv

    $env:ChocolateyInstall is null; which is to be expected because the env hasn't yet been re-read.

    refreshenv doesn't work because that is a command that choco installed to the env path that hasn't been refreshed yet. Both commands will work great after the env is refreshed. The question is how to refresh the env before I can run the command to refresh the env?



  • I have never had it be accessible to screen connect until a reboot. But I rarely install it this way, so memory is fuzzy.

    I guess you could cycle the screenconnect client service. That should do the same.



  • I find it sometimes available, and sometimes not. But the situation here is definitely just the env not being picked up yet.



  • @JaredBusch said in Chocolatey not available after being installed through ScreenConnect:

    I guess you could cycle the screenconnect client service. That should do the same.

    This did it; thanks. It's the only working solution short of a reboot. I did not want to connect to the client with SC so I pushed a re-install, it was current, so it just went through the motions and restarted the services. Perfect for my needs.