The writeprivateprofstring Command

writeprivateprofstring is a general purpose script command that writes to (or deletes from) an agent side database, specifically to the registry under the PDB registry path, as well as to the pdb.ini file.

Important: writeprivateprofstring is a powerful script. Use with caution.

Syntax

Write writeprivateprofstring scripts using the following syntax:

writeprivateprofstring section [key] [value]

Where:

  • section is the name of the section in the .ini file to which the value will be written. If the section does not exist, it will be created. The name of the section is case-sensitive.
  • key is the name of the key. If the key does not exist in the specified section, it will be created. If this parameter is not entered, the entire section (including all entries within it) will be deleted.
  • value is the string to be written to the file. If this parameter is not entered, the key will be deleted.
Note: Use quotation marks if either the key or value contain spaces.

Examples

Description Syntax
Changes a device's name writeprivateprofstring Device DeviceName MyDevice
Changes the orientation of the display image of a device that is remote controlled.

Requires

  • Android
writeprivateprofstring RcOrientationFix manufacturer model value

Where

  • manufacturer is from android.os.Build.MANUFACTURER("ro.product.manufacturer") and falling back to android.os.Build.BRAND("ro.product.brand") if the manufacturer is unknown
  • modelis from android.os.Build.MODEL("ro.product.model")
  • value is one of the following:
    • CW for clockwise
    • CCW for counter-clockwise
    • NONE for no rotation
    • UPSIDEDOWN for upside-down
Specifies the minimum WiFi security level on a device

Requires

  • Android Enterprise
writeprivateprofstring DeviceFeature MinimumWifiSecurityLevel securityLevel apply featurecontrol

Where securityLevel is one of the following values:

  • 0 sets the WiFi security level to Open
  • 1 sets the WiFi security level to WEP
  • 2 sets the WiFi security level to WPA
  • 3 sets the WiFi security level to EAP LEAP
  • 4 sets the WiFi security level to EAP FAST
  • 5 sets the WiFi security level to EAP TTLS
  • 6 sets the WiFi security level to EAP TLS
Controls system updates

Requires

  • Android Enterprise (Work Managed) with an agent 13.9.0 or later.
  • 0 is the default option and represents the device's default behavior. Use when you want to remove a system update policy.
  • 1 is Automatic. The system update installs automatically as soon as an update is available
  • 2 is Windowed. The system update is installed automatically when the system clock is inside the specified daily maintenance window. If the update has not been installed within 30 days, the system reverts to the default update policy.
  • 3 is Postpone. The system update is postponed for 30 days. After 30 days, the system reverts to the default policy.
  • apply SystemUpdatePolicy is the last line of your script.

For windowed 2, add the following commands:

writeprivateprofstring SystemUpdatePolicy StartTime minute

writeprivateprofstring SystemUpdatePolicy EndTime minute

Where

  • StartTime is the start of the maintenance window.
  • EndTime is the end of the maintenance window.
  • minute indicates the number of minutes from midnight when the window opens or closes.
Note: You can add Freeze Periods on top of your system update policies. A freeze period stops all updates during the specified time frame. When the freeze period is inactive, the regular system update policy applies.

Freeze periods can last up to 90 days. You can set multiple freeze periods but they cannot overlap and there must be at least 60 days between freeze periods. Freeze periods can cross year boundaries so you can set a freeze that lasts from 12-12 to 02-13 (December 12 to February 13).

Supported on Android 9 and later.

To set a freeze period, add this command: writeprivateprofstring SystemUpdatePolicy UpdateFreezePeriodCount number

Where

  • number is the number of freeze periods you want to set.

Then, for each freeze period add:

writeprivateprofstring SystemUpdatePolicy UpdateFreezePeriodStartDatenumber "monthDay"

writeprivateprofstring SystemUpdatePolicy UpdateFreezePeriodEndDatenumber "monthDay"

Where

  • The number in UpdateFreezePeriodStartDatenumber and UpdateFreezePeriodEndDatenumber is a number that identifies the matching start and end dates of the freeze periods.
  • monthDay is the start or end of the freeze period, in the format of MM-DD. So October 19 becomes 10-19

Examples:

To postpone a system update for 30 days:

writeprivateprofstring SystemUpdatePolicy SystemUpdatePolicy 3
apply SystemUpdatePolicy

To set a maintenance window between 1 and 6 AM for system updates with a summer holiday and a winter holiday freeze period:

writeprivateprofstring SystemUpdatePolicy SystemUpdatePolicy 2
writeprivateprofstring SystemUpdatePolicy StartTime 60
writeprivateprofstring SystemUpdatePolicy EndTime 360
writeprivateprofstring SystemUpdatePolicy UpdateFreezePeriodCount 2
writeprivateprofstring SystemUpdatePolicy UpdateFreezePeriodStartDate0 "06-01"
writeprivateprofstring SystemUpdatePolicy UpdateFreezePeriodEndDate0 "09-01"
writeprivateprofstring SystemUpdatePolicy UpdateFreezePeriodStartDate1 "12-22"
writeprivateprofstring SystemUpdatePolicy UpdateFreezePeriodEndDate1 "01-07"
apply SystemUpdatePolicy