Working on some scripting in ExtendScript and need to delete a setting you've saved to your users' preferences file? Did some looking around and it seems there was no known way. Until now!

Found that you can use the preferences.deletePref() method to delete settings. Just need to target it with the prefix "Settings_", and save the prefs file afterward, but otherwise seems to work just fine.

The only caveat here is that the section header will remain, however that seems to have no negative effect.

var sectionTag = "testSectionTag";
var keyTag = "testKeyTag";
var keyValue = "I'm only temporary!";

// Sample save + call
app.settings.saveSetting(sectionTag, keyTag, keyValue);

if (app.settings.haveSetting(sectionTag, keyTag) == true) {
    alert(app.settings.getSetting(sectionTag, keyTag));
}

// The magic delete
app.preferences.deletePref("Settings_" + sectionTag, keyTag);
app.preferences.saveToDisk();

Looking for some more, broader scripting resources? Take a look at this roundup!