Click here to Skip to main content
15,910,877 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.

C++
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().

C++
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/*USE_IPC*/;
	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?
Posted

1 solution

So I work around this problem by called Net.exe with parameter "use " along with other parameters. Could not make the api work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900