kangyu-california / PersistentWindows

fork of http://www.ninjacrab.com/persistent-windows/ with windows 10 update
GNU General Public License v3.0
1.45k stars 50 forks source link

PersistentWindows.exe fails to find a directory, crashes within a couple of seconds #346

Closed crasshacker closed 2 months ago

crasshacker commented 3 months ago

When I run PersistentWindows.exe from the command line (from a PowerShell prompt running as Administrator, on Windows 11 24H2), then immediately run "Get-Process persist" I see two PersistentWindows.exe instances running, but a few seconds later those PersistentWindows.exe processes are no longer running. Looking at the Windows Event Viewer, I see a few errors, one of them coming from the .NET Runtime:

Application: PersistentWindows.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.DirectoryNotFoundException at System.IO.__Error.WinIOError(Int32, System.String) at System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean, Boolean) at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions, System.String, Boolean, Boolean, Boolean) at System.IO.StreamWriter.CreateFile(System.String, Boolean, Boolean) at System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding, Int32, Boolean) at System.IO.File.InternalWriteAllText(System.String, System.String, System.Text.Encoding, Boolean) at PersistentWindows.SystrayShell.Program.Restart(Int32) at PersistentWindows.SystrayShell.Program.WaitTaskbarReady() at PersistentWindows.SystrayShell.Program.Main(System.String[])

So it appears that PersistentWindows.exe is looking for a non-existent directory, and failing when it can't find that directory. I took a quick look at the source code, and it appears that the offending call is located in the Program.cs file in the SystrayShell project, specifically at the File.WriteAllText call in the Restart(int delay) method. My development environment is currently broken so I haven't yet tried to debug this, to understand what non-existent directory the batFile variable in this Restart method is referencing. Whatever it is, it appears not to exist on my computer.

kangyu-california commented 3 months ago

Please try latest patch PersistentWindows5.57_patch2.zip