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?
 
jkrConnect With a Mentor Commented:
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
 
mruffAuthor Commented:
Thanks,
I'm running the service now under an account that has network access, now it works, cool
0
All Courses

From novice to tech pro — start learning today.