karikari
karikari

Reputation: 6817

How to use CreateProcessWithLogonW in c++?

Below is my code. The function is called, but it does not work. It dont call the exe. Why?

int Createprocesslogon()
{
STARTUPINFOW su_info;
ZeroMemory(&su_info, sizeof(STARTUPINFOW));
su_info.cb = sizeof(STARTUPINFOW);

PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
CreateProcessWithLogonW(L"xxx", L"localhost", L"123456", 0, L"C:\\Program Files\\app\\IECapt.exe" ,L" --url=http://www.facebook.com/ --out=test.png --min-width=1024", 0, NULL, NULL, &su_info, &pi);

cout << "testt";

return 0;
}

Upvotes: 0

Views: 3771

Answers (2)

Ajay
Ajay

Reputation: 18429

Did you mean CreateProcessAsUser, or CreateProcessWithToken after a call to LogonUser?

EDIT: Try this (embedding argument in one):

CreateProcessWithLogonW(L"xxx", L"localhost", L"123456", 0, 0,
L"\"C:\\Program Files\\app\\IECapt.exe\" \" --url=http://www.facebook.com/ --out=test.png --min-width=1024\"", 0, NULL, NULL, &su_info, &pi);  

Upvotes: 2

Ben Voigt
Ben Voigt

Reputation: 283733

lpCommandLine is supposed to be the entire command line, starting with the executable (properly quoted). Otherwise your first argument ends up in argv[0] and is ignored by the program.

Upvotes: 0

Related Questions