Hi,
I am trying to run a exe present in the UNC path using CreateProcess, specifying the full UNC path and the parameters as the arguments to the API.
CreateProcess(strConfigUtilPath.c_str(),(LPWSTR)strParams.c_str(),NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi)
On Windows 7 this returns me the error 1326 - log on failure. To counter this I tried to use NetUseAdd() to establish the connection before calling CreateProcess().
USE_INFO_2 UserInfo = {0};
UserInfo.ui2_local = L"\0";
UserInfo.ui2_remote = L"\\\\10.195.5.195\\ConfigUtil";
UserInfo.ui2_password = (LPWSTR)L"password";
UserInfo.ui2_asg_type = USE_DISKDEV;
UserInfo.ui2_username = (LPWSTR)L"Someuser";
UserInfo.ui2_domainname = L"Somedomain";
UserInfo.ui2_refcount=0;
UserInfo.ui2_status =0;
UserInfo.ui2_usecount=0;
DWORD ParmError=0;
NET_API_STATUS status = NetUseAdd(szServerName,2,(LPBYTE)&UserInfo,&ParmError);
But NetUseAdd() also returns the same error code 1326.
What am I doing wrong? How can I make this work ? Any other way to achieve this job?