CreateProfile function

Creates a new user profile.

Syntax

USERENVAPI HRESULT CreateProfile(
  LPCWSTR pszUserSid,
  LPCWSTR pszUserName,
  LPWSTR  pszProfilePath,
  DWORD   cchProfilePath
);

Parameters

pszUserSid

Type: LPCWSTR

Pointer to the SID of the user as a string.

pszUserName

Type: LPCWSTR

The user name of the new user. This name is used as the base name for the profile directory.

pszProfilePath

Type: LPWSTR

When this function returns, contains a pointer to the full path of the profile.

cchProfilePath

Type: DWORD

Size of the buffer pointed to by pszProfilePath, in characters.

Return Value

Type: HRESULT

Returns S_OK if successful, or an error value otherwise, including the following:

Return code Description
E_ACCESSDENIED
The caller does not have a sufficient permission level to create the profile.
HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)
A profile already exists for the specified user.

Remarks

The caller must have administrator privileges to call this function.

Requirements

   
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header userenv.h
Library Userenv.lib
DLL Userenv.dll