The solution i found is to use the CreateService function with user and password parameters set. Ex: -------------------------------------------------------------------------------- CString user = _T(".\\User"); CString pswd = _T("pswd"); LPSTR u = user.GetBuffer(user.GetLength()+1); LPSTR p = pswd.GetBuffer(pswd.GetLength()+1); SC_HANDLE hService = ::CreateService( hSCM, m_szServiceName, m_szServiceName, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, szFilePath, NULL, NULL, _T("RPCSS\0"), u, p); -------------------------------------------------------------------------------- To create the connection: -------------------------------------------------------------------------------- NETRESOURCE nr; char* a = new char[MAX_PATH]; memset(a, 0, MAX_PATH); char* b = new char[MAX_PATH]; memset(b, 0, MAX_PATH); strcpy(a, (char*)"\\\\alma\\geza"); strcpy(b,(char*)"x:"); char pswd[20] = "pswd"; char account[20] = "user"; nr.lpRemoteName = a; nr.lpLocalName = b; nr.lpProvider = NULL; nr.dwType = RESOURCETYPE_DISK; DWORD flags = CONNECT_UPDATE_PROFILE; DWORD res; res = WNetAddConnection2(&nr, (char*)pswd, (char*)account, flags); delete []a; delete []b; if (res == NO_ERROR) return TRUE; else return FALSE;