Edit the Multi SZ Registry with PowerShell

Written by Alex Marin · November 23rd, 2023

In the labyrinth of Windows Registry data types, there's a special one that stands out for its ability to juggle multiple strings in a single act.

It’s the REG_MULTI_SZ registry data type, often referred to as "Multiple Strings" or "Multi-String Values". This data type is an essential part of the Windows registry, known for its capability to store multiple strings or string values within a single registry entry.

REG_MULTI_SZ is a binary data type in the Windows registry, but it stores data in a specific textual format. It is used to hold an array of null-terminated strings, where each string is separated by a double null character (`\0\0`). This unique structure allows it to store multiple values within a single registry entry.

REG_MULTI_SZ is commonly used to store configuration settings, such as environment variables, service dependencies, or lists of values, where maintaining multiple items in a single registry entry is convenient.

In this article, let us explore how you can manipulate the REG_MULTI_SZ with Advanced Installer and PowerShell.

Working with REG_MULTI_SZ and Advanced Installer

Imagine Advanced Installer as your stage director or managing REG_MULTI_SZ entries. Working with Advanced Installer to manipulate registry entries makes developing your installer package so much easier.

It's a breeze to navigate to the Registry Page and choose your hive:

  • HKEY_CLASSES_ROOT,
  • HKEY_CURRENT_USER,
  • HKEY_LOCAL_MACHINE,
  • or HKEY_USERS.

The "Current user / Local machine" hive adapts its performance based on whether your show is for one user or the whole machine – HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE.

Creating a new REG_MULTI_SZ value:

1. Go to the desired registry location,

2. Right-click on the right pane and select New Value.

3. A registry value can be of the following types:

  1. string (REG_SZ or REG_MULTI_SZ),
  2. expandable string (REG_EXPAND_SZ),
  3. integer (REG_DWORD), or binary (REG_BINARY).

4. Enter the strings that make up a REG_MULTI_SZ value, one per line, to define it.

NoteRemember, no empty lines preceding or following a string value. They will be stripped automatically.

REG_MULTI_SZ registry edit

Ready to take the spotlight in registry management?

Get your hands on Advanced Installer’s 30-day free trial, and start developing your installer packages with confidence.

Working with REG_MULTI_SZ and PowerShell

When working with REG_MULTI_SZ values in PowerShell, you typically read and write them as arrays of strings.

PowerShell makes it easy to manipulate and manage these values using cmdlets like Get-ItemProperty and Set-ItemProperty.

# Reading a REG_MULTI_SZ value
   $registryPath = 'HKLM:\Software\Example'
   $multiStringValue = Get-ItemProperty -Path $registryPath | Select-Object -ExpandProperty MultiStringProperty
Get-ItemProperty REG_MULTI_SZ in PowerShell
# Writing a REG_MULTI_SZ value
   $newMultiStringValue = @('Value1', 'Value2', 'Value3')
   Set-ItemProperty -Path $registryPath -Name MultiStringProperty -Value $newMultiStringValue -Type MultiString
Set-ItemProperty REG_MULTI_SZ in PowerShell

The Art of REG_MULTI_SZ Maintenance

Editing REG_MULTI_SZ values is a delicate art. Each string must end with a \0, and the array concludes with a \0\0 encore. Mishandling the null-terminated structure is like missing a step in a tango - it could lead to a data disaster.

Handle REG_MULTI_SZ values with the grace of a ballet dancer to maintain data integrity. A misstep, like removing null characters or introducing formatting faux pas, can turn your data performance into a tragedy.

Conclusion

In summary, REG_MULTI_SZ is a versatile and vital performer in the Windows Registry theatre.

It's a favorite among system administrators and developers for its ability to hold multiple strings in a single registry entry. With PowerShell as your stagehand, managing these values becomes an elegant performance.

Just remember, with great power comes the responsibility to maintain the integrity of your data show. Bravo!

Written by
See author's page
Alex Marin

Application Packaging and SCCM Deployments specialist, solutions finder, Technical Writer at Advanced Installer.

Comments: