Different results in Form .ps1 vs .exe

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 2 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
harringg
Posts: 18
Last visit: Mon Oct 30, 2023 11:13 am

Different results in Form .ps1 vs .exe

Post by harringg »

I've got a small WinForm that checks if a Get-WindowsCapability item is installed (requires Admin rights to check).

I've saved .PSF as Export.ps1 and Export.exe (x64 and x86 both)

When dot-sourcing the .ps1 file, it works as expected, when running the .exe file, it reports that the RSAT item isn't installed. I've got an if-else and that part works, because it thinks its not installed.

Wondering what is different in the .exe
2021-07-15_20-11-48.png
2021-07-15_20-11-48.png (38.12 KiB) Viewed 2771 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Different results in Form .ps1 vs .exe

Post by jvierra »

Sorry but images won't tell us anything. Why dotsource anything? It is only useful to load referenced functions as global functions.

It sounds like you are getting an undetected error or null from some missing function.
User avatar
harringg
Posts: 18
Last visit: Mon Oct 30, 2023 11:13 am

Re: Different results in Form .ps1 vs .exe

Post by harringg »

I just meant they are the same .psf, one export to file (.ps1) and one Build (.exe) I may have used the term dot-source incorrectly.

.ps1 was run via an elevated PS session
PS> . 'export.ps1'
.exe was run, right-click, Run As Adminstrator
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Different results in Form .ps1 vs .exe

Post by jvierra »

WStill not enough information to know what you are doing.
This topic is 2 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked