Click to See Complete Forum and Search --> : How to use CreateProcessWithLogonW


adegbola
January 25th, 2003, 01:07 PM
I have been trying to get my code to log on as another user and start a process on the local computer "ROUGHRIDER8" using another local users credentials "oluwaseun/oluwaseun".
My code generates error 87 i.e. The parameter is incorrect. ERROR_INVALID_PARAMETER
Can anyone offer code that works or any guideline on this new SDK API. My Operating system is Windows 2000 using Visual C++ 6.0 SP4
Cheers
Gbola
Code
BOOL ki=CreateProcessWithLogonW(
L"oluwaseun", // user's name
L"ROUGHRIDER8", // user's domain
L"oluwaseun", // user's password
CREATE_DEFAULT_ERROR_MODE+CREATE_NEW_CONSOLE+CREATE_NEW_PROCESS_GROUP,//LOGON_NETCREDENTIALS_ONLY, // logon option
(LPCWSTR)&jola[0], // executable module name
NULL, // command-line string
NORMAL_PRIORITY_CLASS, // creation flags
NULL, // new environment block
L"c:\\", // current directory name
NULL, // startup information
&procinfo // process information
);

DanM
January 25th, 2003, 01:21 PM
You have to use OR to combine flags:

CREATE_DEFAULT_ERROR_MODE+CREATE_NEW_CONSOLE+CREATE_NEW_PROCESS_GROUP

should be changed to:

CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP

Also make sure the jola variable is declared a WCHAR not char (you didn't provide us the declaration of this variable)


Dan

The Saint
February 14th, 2003, 09:45 AM
Hi folks,
I am currently facing the problem as specified in the topic question. All I need to do is logon to a remote machine in the LAN and start an executable. The catch is I cannot use sockets. CreateProcessWithLogonW allows me to logon to the domain on my own machine using a different user id and password but how to achieve the same on a remote machine. Is it possible? If yes, kindly guide me.
ciao.

Bob Davis
February 16th, 2003, 11:30 AM
I don't believe that's possible. If you want to logon to another machine, you'll have to use some sort of socket to communicate with it at some point. Why aren't you allowed to use sockets?

The Saint
February 17th, 2003, 06:53 AM
Hi mate,
I actually need to do this for our client. And he does not want us to use sockets. Guess will have to talk to the client. Will try to update regularly.
ciao