<p>I'm trying to start a service as a user and things work fine, until I try a user that doesn't have a password. Then, it fails to start (due to log-on error).</p>

<p>Am I doing something wrong or is this "by design"?</p>

<p>The code to register this service:</p>

<pre><code>    SC_HANDLE schService = CreateService( 
        schSCManager,           
        strNameNoSpaces,      
        strServiceName,           
        SERVICE_ALL_ACCESS,       
        SERVICE_WIN32_OWN_PROCESS, 
        SERVICE_AUTO_START,    
        SERVICE_ERROR_NORMAL,      
        szPath,                  
        NULL,                     
        NULL,                  
        NULL,                    
        strUser,
        (strPassword.IsEmpty())?NULL:strPassword);
</code></pre>

You need to specify an empty string, not NULL if there is no password. NULL is not a valid empty string, "" is. Probably you should just pass
```
strPassword
```
for the last parameter.
```
```
SC_HANDLE schService = CreateService( 
            schSCManager,           
            strNameNoSpaces,      
            strServiceName,           
            SERVICE_ALL_ACCESS,       
            SERVICE_WIN32_OWN_PROCESS, 
            SERVICE_AUTO_START,    
            SERVICE_ERROR_NORMAL,      
            szPath,                  
            NULL,                     
            NULL,                  
            NULL,                    
            strUser,

// change this line to:
            strPassword.IsEmpty() ? L"" : strPassword);
// or maybe
            strPassword);
```
```