Running Custom Actions

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION 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.

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 2 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
B Daring
Posts: 90
Last visit: Mon Feb 05, 2024 3:00 pm
Answers: 2
Has voted: 1 time

Running Custom Actions

Post by B Daring »

Greetings,

Product, version and build: 5.8.196
Operating system: Win10 21H1
PowerShell version(s): 5.1.19041.1237

I am new to this studio thing. But not new to IDE stuff. What I am wondering is, what is the best way to package a MSI installer and have the installer run a custom script to edit the registry? I have tried a powershell script but I can't be sure that the end user will have, Set-ExecutionPolicy, set. I then tried to run a batch file but I don't think the batch file has the correct permissions either on the install. Same goes for a VB.net exe to edit the registry. So I am curious what is the best way to do this? Am I just missing a setting in Studio to make it happen? Any setting I use under Custom Actions always stops on check code and errors out stating a program required for this install to complete could not be run.
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 7:24 am
Answers: 39
Been upvoted: 30 times

Re: Running Custom Actions

Post by brittneyr »

You can always package your PowerShell script as an executable with our packager. I'm not sure how you have your settings configured, but if your MSI is running as an administrator, any custom actions will also run as an administrator.

Based on the error you are getting, does your script require any of the files that are being installed with MSI? When is your custom action executing (immediately, when the system is being modified, during installation rollback, or after the system has been successfully modified)?

Does the file you are attempting to run as a custom action work outside of the MSI?
Brittney
SAPIEN Technologies, Inc.
User avatar
B Daring
Posts: 90
Last visit: Mon Feb 05, 2024 3:00 pm
Answers: 2
Has voted: 1 time

Re: Running Custom Actions

Post by B Daring »

Thanks Brittneyr,

Yes, it is running as administrator. Yes the script runs great outside of the installer, if I run it as administrator. I have tried the three settings, (immediately, when the system is being modified, and after the system has been successfully modified). I have tried 3 different methods. A cmd batch file, a ps1 file and a vb.net exe file with no luck. I see the command window and the powershell window open and close real fast but the reg setting never gets set.
Based on the error you are getting, does your script require any of the files that are being installed with MSI?"
No, it runs independent.
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 7:24 am
Answers: 39
Been upvoted: 30 times

Re: Running Custom Actions

Post by brittneyr »

The following article includes an example of custom actions to set and remove the registry values:
https://www.sapien.com/blog/2018/02/26/ ... i-builder/

The article is older and says its for PrimalScript, but it is still applicable.
Brittney
SAPIEN Technologies, Inc.
User avatar
B Daring
Posts: 90
Last visit: Mon Feb 05, 2024 3:00 pm
Answers: 2
Has voted: 1 time

Re: Running Custom Actions

Post by B Daring »

Yeah I read that page and downloaded the files. I set mine Actions up just like yours and set my script just like your setvalue script and still no dice, still doesn't add the reg key. The powershell screen comes up and goes away real fast. I'm trying to add a key here

HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Running Custom Actions

Post by Alexander Riedel »

This may sound like a silly question, but I ask anyway:
Did you actually add the script the custom action is supposed to run to your installer?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
B Daring
Posts: 90
Last visit: Mon Feb 05, 2024 3:00 pm
Answers: 2
Has voted: 1 time

Re: Running Custom Actions

Post by B Daring »

Not a silly question Alexander, lol

Yes, I added it and have it set to "when the system is being modified, Wait for custom action to finish, and checked for install and Maintenance". Is there another spot beside Custom Action?

[edit]
I did just try to add my .net version of adding the reg key and added it to the files and folders section as well and this time I get no permissions to edit registry. so that means the custom action is not being run as admin
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Running Custom Actions

Post by Alexander Riedel »

That all depends on your settings. Can you share the PSBuild file?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Running Custom Actions

Post by Alexander Riedel »

I am also not sure what you mean by "add my .net version of adding the reg key". Can you elaborate please?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
B Daring
Posts: 90
Last visit: Mon Feb 05, 2024 3:00 pm
Answers: 2
Has voted: 1 time

Re: Running Custom Actions

Post by B Daring »

Sure, I made a VB.NET script to edit the registry so it was all incapsulated. It is very basic, tells me it did edit the registry or it did not edit it.
Last edited by B Daring on Tue Jan 11, 2022 9:34 am, edited 1 time in total.
This topic is 2 years and 2 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.