all groups > dotnet interop > january 2005 >
You're in the

dotnet interop

group:

Mapping with CreateProcess


Mapping with CreateProcess Ed McAndrew
1/31/2005 2:49:11 PM
dotnet interop:
I'm trying to map a network drive share in c# with:

CreateProcess("net", @"use " + LocDrive + " " + Quotes + userShare + Quotes
+ " " + userPass + " /USER:" + userName, out exitCode, out output);

Everything is right, and it works perfectly when the compiled executable is
launched manually from a command line.

However; when I attempt to use this console app from a scheduled task, the
create process event fails. I'm not sure what is going on. There are no
exceptions being thrown at all. The output is simply null

The purpose of this executable is to run the app as a scheduled task every
10 minutes to ensure that a drive mapping is still connected.

I'm not sure how much code or what code of mine you would like to see.

Thanks in advance,

Re: Mapping with CreateProcess Daniel Petersson, Cefalo
1/31/2005 10:25:02 PM
Check the network management API instead, either from
managed C++ or throuh PInvoke.

// daniel

[quoted text, click to view]
Re: Mapping with CreateProcess Ben Rush
1/31/2005 11:44:15 PM
Hello Ed,

What user are you running your task under; what are the permissions? It's
possible the user might not have appropriate priviledges to create the
process.


[quoted text, click to view]

Re: Mapping with CreateProcess Ed McAndrew
2/1/2005 5:41:05 AM
Thanks Ben,

What I've done is to rob the example code from microsoft for user account
impersonation. Within the app, I'm authenticating (verified by intentionally
supplying an incorrect password and catching the exception) to the domain
with a domain administrator account. I do believe however that this is in
fact close to the problem, as it seems most likely as when I run the app
manually, it would be using my credentials. However, when run as a task, it
should be using my supplied credentials as well (which is failing), so I'm at
a loss for explaining that :l

[quoted text, click to view]
Re: Mapping with CreateProcess Ed McAndrew
2/1/2005 5:43:03 AM
Daniel,

I've tried switching to PInvoke. I still encounter the problem :/

[quoted text, click to view]
AddThis Social Bookmark Button