Powershell Windows Service - Not a valid Win32 Application

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
This topic is 1 year and 10 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.
Drunkpenguin
Posts: 6
Last visit: Tue Jan 16, 2024 3:03 am

Powershell Windows Service - Not a valid Win32 Application

Post by Drunkpenguin »

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: Powershell Studio 2021 5.8.187
Operating system: Windows 10 Pro 20H2 64-bit
PowerShell version(s): 5.1.19041.1645
32-bit version of software?

I'm having a bit of an issue with installing a service created through Powershell Studio. The service isn't very complex, and if I execute the code in a while-loop in normal Windows Powershell ISE, it works fine and I can blatantly enjoy my coffee.

Now I've spotted the possibility to create an MSI to install the service. So of course the curious and lazy lad I am, I tried to get that working. I've added some screenshots for you to see my configuration. I am not really sure what is important in this case, so I just made a few screenshots of the Installer Configuration, since I think that's the one I need for the msi Installer. At least was that my interpretation. If that is not the case, I would be obliged to learn differently. Please note that I am not yet very experienced with this, so please apologise any... ahem... inelegant configurations.

However, when I install it, I cant start it. According to the system Windows Log, the Service is not a valid Win32 Application. I tried various configurations in the installer configuration. However, there was more the strategy of "let's see what this button does'.

Any Ideas on how to troubleshoot or even solve this cheeky problem?

Thanks in advance
Attachments
2022-05-02 15_40_17-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png
2022-05-02 15_40_17-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png (8.71 KiB) Viewed 7852 times
2022-05-02 15_40_10-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png
2022-05-02 15_40_10-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png (18.83 KiB) Viewed 7852 times
2022-05-02 15_40_02-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png
2022-05-02 15_40_02-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png (18.25 KiB) Viewed 7852 times
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Powershell Windows Service - Not a valid Win32 Application

Post by brittneyr »

From your screenshots, I do not see your executable listed in Files and Folders. Please try adding it and then rebuilding your MSI.
Brittney
SAPIEN Technologies, Inc.
Drunkpenguin
Posts: 6
Last visit: Tue Jan 16, 2024 3:03 am

Re: Powershell Windows Service - Not a valid Win32 Application

Post by Drunkpenguin »

Thanks for your fast response

So do I understand this correctly: For this to work, I need the executable, which I package, included in the files and folders of the msi installer? Now that you're saying, starting to make sense I suppose. Do I also need to add the startup.pss and the needed ps1 files in the (which I dot source in startup.pss) in the files and folders? Or is it enough to check "Resolve and include external scripts" at Output Settings of the packager configuration?

EDIT:

I've included the pss and the exe which I package before, doesnt work. More Screenshots ahead. I've now also added some screenshots of the Packager Configuration
Attachments
2022-05-02 16_41_13-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png
2022-05-02 16_41_13-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png (13.86 KiB) Viewed 7835 times
2022-05-02 16_41_03-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png
2022-05-02 16_41_03-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png (32.8 KiB) Viewed 7835 times
2022-05-02 16_40_53-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png
2022-05-02 16_40_53-cockpit_Service.psproj.psbuild - SAPIEN Script Packager.png (13.57 KiB) Viewed 7835 times
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Powershell Windows Service - Not a valid Win32 Application

Post by brittneyr »

Yes, your executable needs to be listed under Files and Folders.

You do not need to add the original project files if you made an executable unless they were included in the project as 'Content'.
When a project builds, it makes a script comprised of all the files included in the project with the Build setting set to 'Include'.

For more information on project settings and the Build setting, you may find the following article helpful:
https://www.sapien.com/blog/2022/03/15/ ... roduction/

The "Resolve and Include external scripts" is for any dot sources files. If script about to be packaged has dot sourced files, the code for those files is embedded into the script at the location of the dot sourced line.
Brittney
SAPIEN Technologies, Inc.
Drunkpenguin
Posts: 6
Last visit: Tue Jan 16, 2024 3:03 am

Re: Powershell Windows Service - Not a valid Win32 Application

Post by Drunkpenguin »

Alright, thank you for the explanation. The Fog of ignorance seems to be lifting. I've now done as you described, and the error still persists. Any other ideas?
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: Powershell Windows Service - Not a valid Win32 Application

Post by brittneyr »

Try changing it so there is only one executable file in Files and Folders with the executable listed first. If you need both 32 and 64 bit, you may need to make two different installers.
Clean the output folder and then rebuild. Do you still get the same error?

Is so, can you please upload your project files here:
https://www.sapien.com/support/upload
Brittney
SAPIEN Technologies, Inc.
Drunkpenguin
Posts: 6
Last visit: Tue Jan 16, 2024 3:03 am

Re: Powershell Windows Service - Not a valid Win32 Application

Post by Drunkpenguin »

brittneyr wrote: Mon May 02, 2022 1:32 pm Try changing it so there is only one executable file in Files and Folders with the executable listed first. If you need both 32 and 64 bit, you may need to make two different installers.
Clean the output folder and then rebuild. Do you still get the same error?

Is so, can you please upload your project files here:
https://www.sapien.com/support/upload
Cheers, that fixed it. Needed the executable first. Thank you very much for your help and I wish you good luck on your journey :D
This topic is 1 year and 10 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.