Repository navigation
Start programs in the current location, and read program paths as PowerShell does - #22
Merged
Merged
Conversation
Programs ran in the PowerShell process's working directory, which cd and Set-Location never change. So after "cd D:\work" at the prompt and then ".\script.ps1", every program started in whatever folder the console opened in. Relative paths in a program's arguments then pointed at the wrong folder: it could fail to find its input, or write its output somewhere unexpected and still report success. A FilePath like .\tool.exe couldn't be started at all, and a relative WorkingDirectory was resolved against the wrong folder too. Start-PkProcess, which every entry point uses, now defaults to the caller's current file-system location, using the real folder behind a New-PSDrive drive and the last file-system location when the current one is HKLM: or similar. A relative WorkingDirectory, and a FilePath with a folder in it, are resolved against that location. Bare names are still found the way Windows finds programs. If the current folder has been deleted, the old default is used. An explicit absolute WorkingDirectory behaves as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lure A WorkingDirectory or FilePath on a drive PowerShell knows, like ~ or one made with New-PSDrive, was passed to Windows untranslated and failed. Those paths are now resolved the way PowerShell resolves them, and anything that isn't a file-system path to PowerShell is still taken relative to the last file-system location. When a program with a relative path can't be started, the error names the full path that was tried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On GitHub's runners %TEMP% is an 8.3 short path (C:\Users\RUNNER~1\...), while PowerShell's current location, and so the folder programs start in, uses the long name. The new working-directory checks compared against the short form and failed although the programs ran in the right folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
Every program the kit started ran in the PowerShell process's working directory.
cdandSet-Locationnever change that folder. So aftercd D:\workat the prompt and then.\script.ps1, every program started in whatever folder the console had opened in: the home folder, or System32 for an admin window. Scripts thatSet-Locationthemselves hit the same thing.FilePathlike.\tool.execouldn't be started at all, even though& .\tool.exeworks in PowerShell.WorkingDirectorywas resolved against the wrong folder. One on a PowerShell drive (~, or a drive made withNew-PSDrive) failed outright.This affects every entry point: the batch, the dispatcher,
Invoke-PkProcessWithTimeoutandStart-PkProcess. Reproduced on Windows PowerShell 5.1 and PowerShell 7.What changed
Start-PkProcess, which every entry point uses, now does the following:New-PSDrivedrive, that's the real folder behind the drive.HKLM:\, say), it's the last file-system location.WorkingDirectory, and aFilePathwith a folder in it, are resolved the way PowerShell resolves paths. That includes~andNew-PSDrivedrives.cjxl.exeis still found the way Windows finds programs, and an explicit absoluteWorkingDirectorybehaves as before.Start-PkProcess/Invoke-PkProcessWithTimeouthelp say what the default is. The README also notes that a.bat/.cmdprogram can't run with a network share (\server\share) as its working folder, becausecmd.exefalls back toC:\Windowsthere.Compatibility: scripts that never change location behave exactly as before. A script that changes location and works today must already pass absolute paths, so it's unaffected too. The one case that gets worse is a
.bat/.cmdprogram run while the current location is a network share.Testing
.\pk-wd.cmd;WorkingDirectory;New-PSDrivelocation, plusFilePathandWorkingDirectoryon that drive;~;WorkingDirectory;main: 8 of the new checks fail (8 FAILED, 249 passed). The other three (the precondition, the deleted folder and the explicitWorkingDirectory) are guards that pass on both.ALL PASSED (257 assertions)on 5.1 and 7.🤖 Generated with Claude Code