Skip to content

Task Scheduler Compatibility Problem #5919

Description

Just installed PowerShell 6.0. Was using 5.1 before.
I updated my scheduled tasks (in the Windows Server Task Scheduler) and I can't name the executable like before. The event gives a 0x80070002 (file not found) error when the task runs.

Checked Path variable, looks fine.
If I put in the full path to pwsh.exe, it works fine. But I'm concerned with doing that since it involves a 6.0.0 folder, which I assume will change.

Please update the installer to fix this shortcoming. (I used PowerShell-6.0.0-win-x64.msi)

1
2

Activity

  1. bergmeister commented on Jan 16, 2018

    @bergmeister
    Contributor

    I briefly looked into it and this is not related to the recently found issue of registry keys being in HKCU in 6.0 since the same happens when using HKLM.
    As a current workaround you can use
    image
    I found that adding a registry key with value C:\Program Files\PowerShell\6.0.0\pwsh.exe and name pwsh (the name itself actually does not matter) in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment would enable your scenario. This is the place in the registry for environment variables.
    But just a word of warning: If you do not have a specific reason to upgrade to 6.0, then sticking to 5.x might be the better (more pain free) solution for Windows for the moment being (although it allows us at least to get more feedback). PowerShell Core was developed to be cross platform and contains many breaking changes and is not meant to replace Windows PowerShell (yet).

  2. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Jan 17, 2018
  3. iSazonov commented on Jan 17, 2018

    @iSazonov
    Collaborator

    You can use full path in Task Schedule C:\Program Files\PowerShell\6.0.0\pwsh.exe

  4. al-ign commented on Jan 17, 2018

    @al-ign
    1. You should not use short names in Task Scheduler for obvious security reasons
    2. Proper way to call any program by short name is adding it's location to PATH environment variable, or using 'App Paths' registry key.
      To use PATH method, add executable location to global PATH, using sysdm.cpl
      To use App Paths, create necessary subkey in 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths' key, for ex:
    new-item 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths' -Name pwsh.exe -Value 'C:\Program Files\PowerShell\6.0.0\pwsh.exe' 
    
    1. Concerning updating installer to support updating PATH and/or App Paths... well, it should.
  5. iSazonov commented on Jan 26, 2018

    @iSazonov
    Collaborator

    @sundarchi1 Feel free create new Issue for enhancing installer to update PATH. We already add $Home to %PATH% since #5101.

  6. lwsrbrts commented on Jan 27, 2018

    @lwsrbrts

    I can see that my PATH variable ($env:Path) already contains the correct location for the pwsh.exe binary but I still get this issue, so adding it to the global PATH variable alone doesn't seem to be a suitable fix - at least not for me.

    PowerShell.exe is located in the App Paths registry location though, so that is probably why that works.

    image

    image

  7. iSazonov commented on Jan 27, 2018

    @iSazonov
    Collaborator

    What is output where.exe pwsh.exe?

  8. lwsrbrts commented on Jan 27, 2018

    @lwsrbrts

    C:\Program Files\PowerShell\6.0.1\pwsh.exe

  9. MaximoTrinidad commented on Jan 27, 2018

    @MaximoTrinidad

    Keep in mind, due to the upcoming new release update(s) to PSCore, the version number will keep changing in the Program Files PowerShell path.

    So, whatever changes to the Environment Variable Path will become useless.

    Now, we are at PSCore 6 version 6.0.1 and not 6.0.0.

    Anything scheduled for PSCore6, the path will need to change manually.
    :)

  10. lwsrbrts commented on Jan 27, 2018

    @lwsrbrts

    Maximo Trinidad (@MaximoTrinidad) - yes, that is basically the exact reason for this issue and my subsequent opening of #6046. The issue has opened wider discussion about what goes in the PATH and/or App Path when there's a side-by-side installation and in the event there is, if the user types in "pwsh.exe" from "cmd.exe", which version is opened?

  11. lwsrbrts commented on Feb 4, 2018

    @lwsrbrts

    @sundarchi1 Ilya (@iSazonov) wrote on #6046 that the App Path was actually already there but was using HKCU, instead of HKLM so registry changes were made to change App Path to be under HKLM in commit #5915 so I guess technically we're just waiting for the next release. The result of other discussions about possible SxS conflicts being that if someone is using SxS then they should really be using the zip and referencing that install manually, should they require it.

  12. lwsrbrts commented on Mar 16, 2018

    @lwsrbrts

    I'm still seeing the problem in 6.0.2 but what is strange is that my system PATH (using cmd.exe) shows no mention at all of C:\Program Files\PowerShell\6.0.2. If I fire up cmd.exe and enter pwsh.exe I get: 'pwsh.exe' is not recognized as an internal or external command, operable program or batch file.

    If however I do $env:path inside PowerShell 6.0.2, the folder location is right there on the top line.

    In Windows PowerShell 5.1, I get the system path.

    I'm going to post this then I'll add C:\Program Files\PowerShell\6.0.2 to the system PATH manually, reboot and see what happens.

    paths

  13. lwsrbrts commented on Mar 16, 2018

    @lwsrbrts

    Once added to the system PATH (and after a reboot) the scheduled task executes as expected.

  14. iSazonov commented on Mar 19, 2018

    @iSazonov
    Collaborator

    We'll use standard install path. Please feedback in PowerShell/PowerShell-RFC#115

  15. TravisEz13 commented on Jul 20, 2018

    @TravisEz13
    Member

    @sundarchi1 Did you follow the instructions here: #5919 (comment)

  16. lwsrbrts commented on Jul 22, 2018

    @lwsrbrts

    Not sure if the same fix for 6.1.0 p4 was applied to 6.0.3 but right after installation of 6.0.3 and before a reboot, the scheduled task didn't run. A reboot later and it worked as expected.

    The system path was updated by the installer (leaving behind the previous entry referring to 6.0.2 however). I imagine that with 6.1 this will no longer be a problem if the installs all go in the same place?

  17. TravisEz13 commented on Jul 23, 2018

    @TravisEz13
    Member

    @sundarchi1 The previews don't add themselves to the path by design. Only Stable builds do, we are considering adding pwsh-preview to the path as we did on Linux and Mac.

  18. bergmeister commented on Jul 23, 2018

    @bergmeister
    Contributor

    In the last community call, it was said that August will be the target for the final release.

  19. SteveL-MSFT commented on Jul 24, 2018

    @SteveL-MSFT
    Member

    @sundarchi1 #7345 should address your issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions