Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a Process with an Impersonated User
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01059576
Message ID:
01059580
Views:
17
This message has been marked as a message which has helped to the initial question of the thread.
Fernando,

This is the way I call this function and it seems working:
* ... skipped...
	DECLARE INTEGER CreateProcessAsUser IN advapi32;
		INTEGER hToken, STRING lpApplicationName, STRING lpCommandLine,;
		INTEGER lpProcessAttributes, INTEGER lpThreadAttributes,;
		INTEGER bInheritHandles, INTEGER dwCreationFlags,;
		INTEGER lpEnvironment, STRING lpCurrentDirectory,;
		STRING @lpStartupInfo, STRING @lpProcessInformation
* ... skipped...
	cProcInfo = REPLICATE(CHR(0), 16)
	cStartInfo = num2dword(68) +;
		num2dword(0) +;
		num2dword(0) +;
		num2dword(0) +;
		num2dword(0) +;
		num2dword(0) +;
		num2dword(0) +;
		num2dword(0) +;
		num2dword(0) +;
		num2dword(0) +;
		num2dword(0) +;
		num2dword(STARTF_USESHOWWINDOW) +;
		num2dword(SW_SHOWNORMAL) +;
		num2dword(0) +;
		num2dword(0) +;
		num2dword(0) +;
		num2dword(0)

	nCreationFlags = NORMAL_PRIORITY_CLASS + CREATE_DEFAULT_ERROR_MODE +;
		CREATE_NEW_CONSOLE+CREATE_NEW_PROCESS_GROUP

	IF CreateProcessAsUser(nToken, cApp, " " + ALLTRIM(cCmd),;
		0,0,0, nCreationFlags,0, cDir, @cStartInfo, @cProcInfo) = 0
		* 1314 = ERROR_PRIVILEGE_NOT_HELD
		? "Error:", GetLastError()
		= CloseHandle(nToken)
		RETURN .F.
	ENDIF
* ... skipped...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform