alter_ego_dev2
Posts: 22
Joined: Wed May 10, 2023 4:09 pm

Custom action (powershell script) fails with error code 1603

I've added a "Run powershell inline script" custom action. The script requires Admin rights and works perfectly fine on my local machine.
The script installs a new device using Windows Device Console (devcon.exe).
Script:

Code: Select all

$operationSystemPostfix = If ([Environment]::Is64BitOperatingSystem) {"x64"} Else {"x32"}
$devconPath = (AI_GetMsiProperty APPDIR) + "\Resources\$operationSystemPostfix\devcon.exe"
$driverPath = (AI_GetMsiProperty APPDIR) + "\Driver\driver.inf"

function installDeviceDriver()
{
    $params = @("install", $driverPath, "driver_identifier")
    & $devconPath $params
}

installDeviceDriver
The installer finishes process with message:
The setup wizard ended prematurely
Click the "Finish" button to exit Setup wizard.
Show log (marked checkbox).

The log file has error description:
...
CustomAction InstallDeviceDriver returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 18:01:47: InstallDeviceDriver. Return value 3.
Action ended 18:01:47: INSTALL. Return value 3.
...
Could you please help with the error? What does it mean? How I can get more information to solve the problem?
Catalin
Posts: 6592
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom action (powershell script) fails with error code 1603

Hello and welcome to our forums,

That means that the custom action failed.

Unfortuantely, there isn't really a way to further investigate this, at least from the log file.

If your custom action needs to run elevated, I would suggest the following:

- schedule it after the "Add resources" action group

- "Execution Time" set to "When the system is being modified (deferred)"

- check the "Run under the LocalSystem account with full privileges (no impersonation)" option to ensure the CA runs elevated

Now, if that does not help, I would suggest further debugging the script using some messageboxes.

You can use the following snippet:

Code: Select all

Add-Type -AssemblyName PresentationFramework
and then:

Code: Select all

[System.Windows.Messagebox]::show("something")
to display a messagebox.

I would start by displaying a messagebox after each variable, to make sure it is correct, e.g.:

Code: Select all

[System.Windows.MessageBox]::show("$devconPath")
and so on.

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Mike34
Posts: 1
Joined: Fri Jul 28, 2023 4:16 am

Re: Custom action (powershell script) fails with error code 1603

Catalin wrote: Thu May 11, 2023 5:01 pm Hello and welcome to our forums,

That means that the custom action failed.

Unfortuantely, there isn't really a way to further investigate this, at least from the log file.

If your custom action needs to run elevated, I would suggest the following:

- schedule it after the "Add resources" action group

- "Execution Time" set to "When the system is being modified (deferred)"

- check the "Run under the LocalSystem account with full privileges (no impersonation)" option to ensure the CA runs elevated

Now, if that does not help, I would suggest further debugging the script using some messageboxes.

You can use the following snippet:

Code: Select all

Add-Type -AssemblyName PresentationFramework
and then:

Code: Select all

[System.Windows.Messagebox]::show("something")
to display a messagebox.

I would start by displaying a messagebox after each variable, to make sure it is correct, e.g.:

Code: Select all

[System.Windows.MessageBox]::show("$devconPath")
and so on lego 2k drive

Hope this helps!

Best regards,
Catalin
Thanks for your suggestion for this problem, I will try it
Catalin
Posts: 6592
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom action (powershell script) fails with error code 1603

You're always welcome, Mike!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”