This is not portable but may be necessary in some captive intranet situations where you know what the target client is going to be and have some control over it.
Although the method appears to be widely available, the values for specifying user preferences certainly have not been standardized and the security implications are also not common to all the platforms. You should be prepared to write some portability support code if you plan to deploy this functionality.
You cannot access this method unless the script has the UniversalPreferencesdRead privilege. Setting preferences requires the UniversalPreferenceWrite privilege.