473,416 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

CreateProcessWithLogonW

Hey, I have a question concerning the CreateProcessWithLogonW function
imported from the advapi32 dll. For some reason I cant get the appName
and cmdLine paramters to work together. For example, I'm trying to use
the Perforce command line utility (p4.exe) to download some files to the
local computer. So I set appName="p4.exe" and cmdLine="print -o
\"c:\\file.txt\" -q \"//depot/files/file.txt\"". So then I call
CreateProcessWithLogonW(username, domain, password,
LogonFlags.LOGON_WITH_PROFILE, appName, cmdLine,
CreationFlags.CREATE_DEFAULT_ERROR_MODE, IntPtr.Zero, null, ref si, out
pi), which runs fine (return non 0) but the file never downloads. The
only workaround I have been able to find so far is to create a console
app and use the process class as:
Process.Start("p4.exe", "print -o \"c:\\file.txt\" -q
\"//depot/files/file.txt\""). Then passing the path of the executable
that gets created to the CreateProcessWithLogonW function as the appName
paramter with cmdLine=null:
CreateProcessWithLogonW(username, domain, password,
LogonFlags.LOGON_WITH_PROFILE, ConsoleExePath, null,
CreationFlags.CREATE_DEFAULT_ERROR_MODE, IntPtr.Zero, null, ref si, out
pi), which works. But this is obviously not a desirable solution since I
would have to create a console app everytime i wanted to download a file
from Perforce from a web app. Any ideas on what I'm doing wrong with the
appName and cmdLine paramters, or anyone know what functions get called
in CreateProcessWithLogonW or how it works so I can possibly try to
duplicate it? Thanks in advance for any help...

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
2 9317
Think of this: Who established the network credentials for the network share
("//depot/files)?

- When using a console application, p4.exe runs in the security context of
the interactive logon user (I assume the one that established the network
credentials for "//depot/files"). The result is that p4.exe can access the
file on the share.
- When using CreateProcessWithLogonW you effectively created a new logon
session, this one has no access to the share, even if the same credentials
are used as the interactive logon user.
The result is that p4.exe cannot access the file on the share.

Your only option to solve this, is to establish a network connection for the
new logon session.

Willy.

"Bilal Dinc" <bd***@factset.com> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...
Hey, I have a question concerning the CreateProcessWithLogonW function
imported from the advapi32 dll. For some reason I cant get the appName
and cmdLine paramters to work together. For example, I'm trying to use
the Perforce command line utility (p4.exe) to download some files to the
local computer. So I set appName="p4.exe" and cmdLine="print -o
\"c:\\file.txt\" -q \"//depot/files/file.txt\"". So then I call
CreateProcessWithLogonW(username, domain, password,
LogonFlags.LOGON_WITH_PROFILE, appName, cmdLine,
CreationFlags.CREATE_DEFAULT_ERROR_MODE, IntPtr.Zero, null, ref si, out
pi), which runs fine (return non 0) but the file never downloads. The
only workaround I have been able to find so far is to create a console
app and use the process class as:
Process.Start("p4.exe", "print -o \"c:\\file.txt\" -q
\"//depot/files/file.txt\""). Then passing the path of the executable
that gets created to the CreateProcessWithLogonW function as the appName
paramter with cmdLine=null:
CreateProcessWithLogonW(username, domain, password,
LogonFlags.LOGON_WITH_PROFILE, ConsoleExePath, null,
CreationFlags.CREATE_DEFAULT_ERROR_MODE, IntPtr.Zero, null, ref si, out
pi), which works. But this is obviously not a desirable solution since I
would have to create a console app everytime i wanted to download a file
from Perforce from a web app. Any ideas on what I'm doing wrong with the
appName and cmdLine paramters, or anyone know what functions get called
in CreateProcessWithLogonW or how it works so I can possibly try to
duplicate it? Thanks in advance for any help...

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #2
Hello Willy

I came across some of your code on a different site, and I had one question about the marshalling. In C# implementation of the CreateProcessWithLogonW code, the "out" parameter is used, I'm thinking because we want to retrieve a handle to the process from the unmanaged side. Is there an equivalent in VB.NET? Would that just be ByRef? My VB.net code seems to be failing when I use byref

Result = CreateProcessWithLogonW(
lpUsername,
lpdomainname,
lpPassword,
LOGON_NETCREDENTIALS_ONLY,
vbNullString,
CommandLine,
NORMAL_PRIORITY_CLASS Or CREATE_UNICODE_ENVIRONMENT,
IntPtr.Zero,
vbNullString,
pStartInfo, pProcessInfo

The Win32 error returned is file not found. Any ideas?
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Arne | last post by:
Hi, I'm working on an asp.net application that reads a users username and password, and starts a process with the username read. The problem is that the program returns value...
2
by: jerry | last post by:
I'm trying to run an application under another user within a winform app writen in C#. I have tried a number of different things, but it seems that the CreateProcessWithLogonW function should work...
10
by: David Davidson | last post by:
I am attempting to use CreateProcessWithLogonW from the server-side code of a web page (yes, I want to create a process on the server) and not having much luck. I am attempting to run VPScan, an...
6
by: Matthew Wieder | last post by:
I have an ASPNET app that is running as the ASPNET machine user. It makes a call to the API CreateProcessWithLogonW. On Windows XP it executes without a problem, but on Windows 2000, I get an...
3
by: Benjamin Bittner | last post by:
Hallo NG, I have problems with calling the CreateProcessWithLogonW() function. I tried converting an VB6 example (http://support.microsoft.com/default.aspx?scid=kb;en-us;285879) and some snippets...
0
by: Todd B | last post by:
Hello, I posted this in the aspnet.security group a few days ago but haven't received any feedback, so I thought I would try this group. Apologies if this is the wrong place. I am...
1
by: ashu.nitc | last post by:
Hi, I am trying to create a process with the API: CreateProcessWithLogonW. The process (say, CMD.EXE) which gets created doesnt have the environment variables which I have explicitly passed into...
1
by: ashu.nitc | last post by:
Hi , I am trying to create process using CreateProcessWithLogonW() API. This works fine on Win2000 and NT, but in Vista it gives a UAC popup before the process (say, notepad, calc, etc) kicks...
2
by: None | last post by:
What's the difference between StartInteractiveClientProcess in http://msdn.microsoft.com/en-us/library/aa379608(VS.85).aspx, and CreateProcessWithLogonW?...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.