MSI builder: set run of ps1/cmd hidden

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 7 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.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

MSI builder: set run of ps1/cmd hidden

Post by stevens »

Hi,

Simple question: how do I run a ps1 in a project (msi builder) hidden?
Found some explanation https://info.sapien.com/index.php/how-t ... si-builder
=> I have some custom actions which run a cmd and a ps1, for both I don't have an option to set it to hidden. Tried the -WindowStyle hidden but that didn't work.



J
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: MSI builder: set run of ps1/cmd hidden

Post by Alexander Riedel »

Windows installer does not have an option to run a console process hidden as far as I know. If it is a PowerShell script, you can package it as a silent exe and use that as your custom action.
As far as CMD goes, there is no direct option. Maybe you can call that from your silent exe, that should give you more options to run it hidden.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: MSI builder: set run of ps1/cmd hidden

Post by stevens »

Making exe from each script is not the way I want to go since I'm editing/testing them all the time.

>You mention "Maybe you can call that from your silent exe, that should give you more options to run it hidden."
How should I do that?
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: MSI builder: set run of ps1/cmd hidden

Post by stevens »

Maybe I could run just 1 ps1 that calls all the other in silent mode?
Then I could finally convert this ps1 to an exe and call it from the msi?
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: MSI builder: set run of ps1/cmd hidden

Post by Alexander Riedel »

That is what I was implying.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: MSI builder: set run of ps1/cmd hidden

Post by stevens »

But how then run the cmd silent?
I need to set set-executionpolicy before I can run any scripts, I do that via the cmd (or can it be done differently?). This cmd also runs/pops up in the msi installer as first to run.
How can I get that silent?
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: MSI builder: set run of ps1/cmd hidden

Post by Alexander Riedel »

Start-process has everything you need.
https://docs.microsoft.com/en-us/powers ... rshell-7.2
A packaged exe is not subject to script execution policy. You can also launch powershell.exe with -executionpolicy bypass,
which is used for a custom action from the MSI if you check the appropriate box in the custom action box.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: MSI builder: set run of ps1/cmd hidden

Post by stevens »

Thanks but doesn't work for me. Script isn't executed during msi installer. It does when I run a powershell ... set-executionpolicy -unrestrcited via cmd
Screenshot_1.png
Screenshot_1.png (12.5 KiB) Viewed 2113 times
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: MSI builder: set run of ps1/cmd hidden

Post by stevens »

Also, when I create an exe of the ps1 via ps2exe and add it to the project, it pops up btw. It's not silent.
User avatar
Alexander Riedel
Posts: 8472
Last visit: Mon Mar 18, 2024 2:59 pm
Answers: 19
Been upvoted: 37 times

Re: MSI builder: set run of ps1/cmd hidden

Post by Alexander Riedel »

For one, I did not say anything about ps2exe. That is not the SAPIEN Script packager. So I would not tell you to use that.
Secondly, from the screenshot, this looks to be something other than a current version.
So why don't we start with what SAPIEN Software and what version do you actually have?
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 1 year and 7 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.