Powershell to EXE Can't find path

I have a basic powershell GUI that I works fine. I compiled it with Powershell Tools and everything works correctly except for one portion. I open and format a txt file from a very specific location and display it in the window. I provide the exact path, and the error shows the correct path, stating the file is not here. I can copy the path into run and open the file.

Any idea on why this in particular would be an issue after converting the file to an executable?

The command I’m using is: Get-Content C:\Test\test.txt | Format-Table | Out-String

It’s stored as variable when the script runs, then displayed later when the function that does so is called.

Tool: Visual Studio, Visual Studio Code, PSScriptPad, PowerShell Module
Version: 

This could have to do with file system virtualization. By default, poshtools exes are 32-bit which could cause some weird stuff to happen. You can disable this by running as administrator or by switch the platform to x64 in the poshtools packaging settings.

That would be my first thing to try. The same thing can happen when accessing the registry.

I have run into that before and I didn’t realize know it defaulted to 32-bit. Thanks.

1 Like

I was trying this today using VSCode. I tried adding the platform parameter with x64 to generated file, but it still creates a 32 bit executable. Tried running VScode as admin to no effect. Is there something I’m missing here?

Disregard. I was checking the executable with sigcheck, which apparently doesn’t work anymore. Verified the platform is x64 and it does work correctly.

1 Like