Service Argument Max Length - Advanced Installer Community
ben.ganley
Posts: 5
Joined: Thu May 14, 2020 8:29 am

Service Argument Max Length

Hi there!

I'm trying to build an installer that installs a service but am facing a limitation under Services to Install -> Context -> Arguments. The input length here seems to be restricted to 255 characters, but my service has a number of arguments that need to be passed to it on boot.

Is there a way of doing so and getting around this 255 character limitation?

Kind regards,
Ben
Catalin
Posts: 7847
Joined: Wed Jun 13, 2018 7:49 am

Re: Service Argument Max Length

Hello Ben,

Although the ServiceInstall table's Arguments column is a "Formatted" string field (ServiceInstall Table docs), and Microsoft's own docs don't state an explicit character cap for it, it looks like it is actually capped at 255 characters.

ServiceInstall Table

This is something common for Microsoft, to not have everything documented properly. :)

This seems to be, as per my research so far, a design-time validation convention of some MSI columns.

I have realized that from the ICE03 article (read the "String overflow" part).

A possible solution to this would be to take advantage of the fact that the Arguments field is formatted and therefore allows us to use properties.

As per my tests, the Properties table, Value column does not inherit the 255 characters cap.

With that in mind, could you please do the following:

- create a property, in the Properties page, with the value of your Arguments field, e.g.:

Name: MY_PROP
Value: your value

- in the Services page, in the Arguments field, use the property we earlier defined, like this:

Code: Select all

[MY_PROP]
From my tests so far, the property can accept more than 250 characters and does not truncate the value.

I have created a property with 260 characters and then retrieved it in a Powershell custom action:

Code: Select all

$propValue = AI_GetMsiProperty MY_PROP

Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.MessageBox]::Show("Length: $($propValue.Length)`n`nValue: $propValue", "Property Test")
which resulted in this:
Screenshot_183.png
Screenshot_183.png (5.51 KiB) Viewed 7428 times

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
ben.ganley
Posts: 5
Joined: Thu May 14, 2020 8:29 am

Re: Service Argument Max Length

Hi Catalin,

Thanks for your response.

What I managed to get working was a Custom Action just before Install Services that sets this property as the string itself contains other args that need to be resolved.

This doesn't seem to have the same length limitation and after running the installer my service starts successfully with the full arg string passed to it.

Thanks for the tip!
Catalin
Posts: 7847
Joined: Wed Jun 13, 2018 7:49 am

Re: Service Argument Max Length

Hello Ben,

Awesome!

Glad to hear you got this working. :D

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

Return to “Common Problems”