Mounting network drive (WNetAddConnection2) problem

Hi,
I've got two programs : A and B
A has code to map a network drive using WNetAddConnection2.
This works fine if I start program a from the command line.
Program B is a NT-service. It's a scheduler which starts other programs according a time-schedule configuration. Program A is a program that is startet from within program B from time to time. Program B starts program A using: _spawnvp(_P_WAIT, CommandFile, Args);
If progam A is started that way by B, the WNetAddConnection2 method in porgam A returns error 1312 (A specified logon session does not exist. It may already have been terminated.
ERROR_NO_SUCH_LOGON_SESSION)
It must have to do that A and B have different sessions?
Do I have to use another method, than _spawnvp to start porgam A?
                             thanks for help martin
mruffAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
The problem is that the service runs under the LocalSystem account, which has almost admin privileges, but *NO* network access (thus the error code - the service has to gather credentials by authenticating to the remote server using a username and a password... and as LocalSystem simply has no password, we're lost). The only solution I can imagine is to set the service to run under a user account which has network access. This can be done by using the services spplet on the control panel and selecting 'start type' or in your call to 'CreateService()'.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mruffAuthor Commented:
Thanks,
I'm running the service now under an account that has network access, now it works, cool
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.