Skip to content

Start-Process: Unable to load DLL 'api-ms-win-core-job-12-1-0.dll' #6561

Closed

Description

@gradinkov

Repro:

Use clean install of Windows 7 SP1 (apparently both x86 and x64 are affected). Then run the following command in PS 6.0.2 ZIP version:

Start-Process "ipconfig" -ArgumentList "/flushdns" -Wait -NoNewWindow

Result:

Start-Process : Unable to load DLL 'api-ms-win-core-job-l2-1-0.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
At line:1 char:1
+ Start-Process -FilePath "C:\7zip\7za.exe" -ArgumentList ("x -oC:\temp ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Start-Process], DllNotFoundException
+ FullyQualifiedErrorId : System.DllNotFoundException,Microsoft.PowerShell.Commands.StartProcessCommand

PowerShell 6.0.2 x86 zip
Windows 7 b7601 SP1 x86 (modern.ie VM)

Works perfectly fine on Win10 x64.

Also tried 6.1.0-preview1, behaves the same way.

Activity

  1. gradinkov commented on Apr 4, 2018

    @gradinkov
    Author

    Actually, way easier to repro:

    Start-Process "ipconfig" -ArgumentList "/flushdns" -Wait -NoNewWindow
    
  2. gradinkov commented on Apr 4, 2018

    @gradinkov
    Author

    Same on 6.1.0-preview1 x86. The user that reported this problem to me uses x64 tho, so apparently this issue affects both arches.

  3. iSazonov commented on Apr 5, 2018

    @iSazonov
    Collaborator

    gradinkov Please replace first repo with simple second in the issue description.

  4. iSazonov commented on Apr 5, 2018

    @iSazonov
    Collaborator

    Mike Richmond (@mirichmo) Could you please comment the Issue?

  5. gradinkov commented on Apr 5, 2018

    @gradinkov
    Author

    Sure thing, done!

  6. gradinkov commented on Apr 5, 2018

    @gradinkov
    Author

    The funny thing is that the commands actually run afterwards, just throw this exception first.

    This is a problem when you run multiple commands in try-catch (as you normally should), which interrupts the rest of the try blocks and thus messes up execution.

    TLDR if you run start-process in try-catch, anything that comes after start-process will be skipped.

  7. mirichmo commented on Apr 5, 2018

    @mirichmo
    Member

    Aditya Patwardhan (@adityapatwardhan) It looks like PowerShell Core needs another API set for Win 7. Do you know if there is a way to scan for compliance (static analysis) rather than checking at runtime?

  8. adityapatwardhan commented on Apr 5, 2018

    @adityapatwardhan
    Member

    The binary does not seem to be in the API set we use : runtime.win7-x64.Microsoft.NETCore.Windows.ApiSets/1.0.1. This needs further investigation.

  9. added
    Issue-Bug
    on Apr 5, 2018
  10. Arnavion commented on May 3, 2018

    @Arnavion

    I hit this on 6.0.1 on win7 x64.

    $ $Error[0].exception.stacktrace
    
       at Microsoft.PowerShell.Commands.NativeMethods.CreateJobObject(IntPtr lpJobAttributes, String lpName)
       at Microsoft.PowerShell.Commands.ProcessCollection..ctor()
       at Microsoft.PowerShell.Commands.StartProcessCommand.BeginProcessing()
       at System.Management.Automation.Cmdlet.DoBeginProcessing()
       at System.Management.Automation.CommandProcessorBase.DoBegin()
    
  11. iSazonov commented on May 3, 2018

    @iSazonov
    Collaborator
  12. Arnavion commented on May 3, 2018

    @Arnavion

    Ilya (@iSazonov) Same thing with current master GitCommitId: v6.1.0-preview.2-26-g84344cbb32ec5e2479e00394951832794bf37244

    Unable to load DLL 'api-ms-win-core-job-l2-1-0.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
       at Microsoft.PowerShell.Commands.NativeMethods.CreateJobObject(IntPtr lpJobAttributes, String lpName)
       at Microsoft.PowerShell.Commands.ProcessCollection..ctor() in C:\Stuff\Sources\PowerShell\src\Microsoft.PowerShell.Commands.Management\commands\management\Process.cs:line 2551
       at Microsoft.PowerShell.Commands.StartProcessCommand.BeginProcessing() in C:\Stuff\Sources\PowerShell\src\Microsoft.PowerShell.Commands.Management\commands\management\Process.cs:line 2018
       at System.Management.Automation.Cmdlet.DoBeginProcessing() in C:\Stuff\Sources\PowerShell\src\System.Management.Automation\engine\cmdlet.cs:line 159
       at System.Management.Automation.CommandProcessorBase.DoBegin() in C:\Stuff\Sources\PowerShell\src\System.Management.Automation\engine\CommandProcessorBase.cs:line 499
    
  13. iSazonov commented on May 3, 2018

    @iSazonov
    Collaborator

    Arnav Singh (@Arnavion) Thanks for confirmation!

  14. meekaah commented on Jul 24, 2018

    @meekaah

    any news? this is completely blocking us 👎 i still havent found a workaround
    we're running windows server 2008 r2

  15. gradinkov commented on Jul 24, 2018

    @gradinkov
    Author

    The fact that after almost 4 months this issue is still open indeed is puzzling. Win7 is officially supported, yet, PowerShell Core is completely broken on it. That means around HALF of your userbase. I'd recommend to either declare Win7 unsupported or fix this critical blocker.

    But I can't just say to my users that "yeah, your OS is theoretically supported, except in practice it won't work". I can't say "a fix is in the works" either coz I haven't seen any real activity on the matter.

  16. iSazonov commented on Jul 24, 2018

    @iSazonov
    Collaborator
  17. adityapatwardhan commented on Jul 28, 2018

    @adityapatwardhan
    Member

    I found a workaround for the issue.

    The issue is with -Wait. You can use -PassThru and wait for the process completion. Something like this:

    $process = Start-Process "ipconfig" -PassThru -NoNewWindow 
    Wait-UntilTrue -sb { $process.HasExited }

    The function Wait-UntilTrue is defined here:
    https://github.com/PowerShell/PowerShell/blob/master/test/tools/Modules/HelpersCommon/HelpersCommon.psm1#L3

    gradinkov meekaah Arnav Singh (@Arnavion)

  18. meekaah commented on Aug 3, 2018

    @meekaah

    Wait-UntilTrue : The term 'Wait-UntilTrue' is not recognized as the name of a cmdlet, function, script file, or... :( how are you using it? are you adding something else? Oh did you have to add that module manually and load it for it to work?

    UPDATE: yeah i added the module manually and it does work as a workaround thanks a lot even if it is sort of a hack 👍

  19. adityapatwardhan commented on Aug 3, 2018

    @adityapatwardhan
    Member

    meekaah The function is defined the link I posted above.

    function Wait-UntilTrue
    {
    [CmdletBinding()]
    param (
    [ScriptBlock]$sb,
    [int]$TimeoutInMilliseconds = 10000,
    [int]$IntervalInMilliseconds = 1000
    )
    # Get the current time
    $startTime = [DateTime]::Now
    # Loop until the script block evaluates to true
    while (-not ($sb.Invoke())) {
    # If the timeout period has passed, return false
    if (([DateTime]::Now - $startTime).TotalMilliseconds -gt $timeoutInMilliseconds) {
    return $false
    }
    # Sleep for the specified interval
    Start-Sleep -Milliseconds $intervalInMilliseconds
    }
    return $true
    }

  20. fdge commented on Aug 22, 2018

    @fdge

    This error is slowing me down from moving From PowerShell to Core
    This error happens on Server 2008 R2 but not on Windows 10 1709

  21. ajax16384 commented on Feb 2, 2019

    @ajax16384

    The issue happens only then Start-Process using -Wait argument.
    Start-Process creates ProcessCollection to monitor child processes which calls NativeMethods.CreateJobObject (

    IntPtr jobObjectHandleIntPtr = NativeMethods.CreateJobObject(IntPtr.Zero, null);
    ).
    "CreateJobObject" declared using pinvoke that points to "api-ms-win-core-job-l2-1-0.dll"(
    internal const string CreateJobObjectDllName = "api-ms-win-core-job-l2-1-0.dll"; /*71*/
    ).
    According to unofficial info this api set was introduced in Windows 8 ( https://www.geoffchappell.com/studies/windows/win32/apisetschema/history/sets62.htm ).
    For some strange reason this api set dll did not included in PowerShell distribution, but many other non "windows 7" api set dll were included.
    So to fix this bug "api-ms-win-core-job-l2-1-0.dll" should be added to redistribute api set files list (
    <File Id="fil2AB41B473A72FD55578EECEEFF2533DB" KeyPath="yes" Source="$(env.ProductSourcePath)\api-ms-win-crt-time-l1-1-0.dll" />
    ) (along with other api set mentioned in PInvokesDllNames)

    Quick dirty fix: droping api-ms-win-core-job-l2-1-0.dll from "windows8/system32" installation to window7/PowerShell/6/ folder will solve issue

  22. ferenczy commented on Aug 22, 2019

    @ferenczy

    One and a half years ago and the issue is still present. Could you let us know what's the plan with this bug, please?

    Windows 7 Ultimate 64-bit
    PowerShell Core 6.2.2

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-BugOS-WindowsResolution-FixedWG-Maintainers-Build

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions