cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
bigwes2000
Level 2

Custom Action to run PowerShell script not working

I created a custom action to run a PowerShell script that will grant full control to the user for files and folders under C:\ProgramData after the install. The script is as follows: icacls "C:\ProgramData\MyCompany\*" /grant Users:F /T. I have tested the script in PowerShell on the target machine and it works. The custom action is not working for some reason. I have the "Run 64-bit PowerShell script" attribute set to No. It is setup to run after the InstallFinalize sequence. There are no conditions set for the install. The powershell script is in a file that is installed with the product. When I look in the install log I see the following information:

MSI (s) (38:60) [10:29:06:239]: Doing action: SetAccessLevel
Action 10:29:06: SetAccessLevel.
Action start 10:29:06: SetAccessLevel.
MSI (s) (38:1C) [10:29:06:295]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSIF2DC.tmp, Entrypoint: m1
MSI (s) (38:F4) [10:29:06:296]: Generating random cookie.
MSI (s) (38:F4) [10:29:06:299]: Created Custom Action Server with PID 14988 (0x3A8C).
MSI (s) (38:F4) [10:29:06:363]: Running as a service.
MSI (s) (38:F4) [10:29:06:365]: Hello, I'm your 32bit Impersonated custom action server.
InstallShield: Attempting to load through CLR 4 APIs...
InstallShield: Getting meta host...
InstallShield: Enumerating available runtimes...
InstallShield: Highest available runtime: v4.0.30319
InstallShield: Trying to use highest runtime...
InstallShield: Using highest version runtime...
InstallShield: Loading assembly ClrPsHelper from resource 4097
InstallShield: Calling method with parameters [(System.UInt32)19, (System.String)C:\Users\wtatkins\AppData\Local\Temp\e60676ed-6e3d-4c0f-8b22-0cddd1fd054a\set_read_write_access.ps1]
Action ended 10:29:07: SetAccessLevel. Return value 1.
Action ended 10:29:07: INSTALL. Return value 1.

Is there a bug preventing the script from running? How can I get this to work?
Labels (1)
0 Kudos

(1) Reply
PaulFazio
Level 2

Have you checked the execution policy on your machine to see if it allows running PowerShell scripts? If it's set to restricted you won't be able to run any PowerShell scripts. That could explain your situation.
0 Kudos