Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Question about using CreateProcessWithLogonW

0 views
Skip to first unread message

George

unread,
Aug 14, 2003, 11:36:29 AM8/14/03
to
I am trying to get an app to run as another user. Below is the code I am
using to call CreateProcessWithLogonW. This code runs without error and
starts the application (notepad in this example) but runs it under the
username of the original user not that of the specified user. If I right
click notepad.exe and select Run As and enter the same user I have in the
example code, it does run notepad as the new user.

The system I am running is WinXP Pro SP1 and VB6 SP5. The target systems
will be WinXP Pro and Win 2000.

Here is my code:

lpUsername = "newuser"
lpDomain = "domain"
lpPassword = "password"
lpApplicationName = "c:\winnt\notepad.exe"
lpCommandLine = vbNullString
lpCurrentDirectory = vbNullString
StartInfo.cb = LenB(StartInfo)
StartInfo.dwFlags = 0&

CreateProcessWithLogonW StrPtr(lpUsername), StrPtr(lpDomain),
StrPtr(lpPassword),
LOGON_NETCREDENTIALS_ONLY, StrPtr(lpApplicationName),
StrPtr(lpCommandLine),
CREATE_DEFAULT_ERROR_MODE Or CREATE_NEW_CONSOLE Or
CREATE_NEW_PROCESS_GROUP,
ByVal 0&, StrPtr(lpCurrentDirectory), StartInfo, ProcessInfo

CloseHandle ProcessInfo.hThread
CloseHandle ProcessInfo.hProcess

Can anyone see what may be a problem.

Thanks


for email remove nospam from the address
gsempl...@ixsis.com


0 new messages