Question Using network drive from Windows Service

pranav_vaidya

Member
Joined
Nov 13, 2008
Messages
6
Location
India
Programming Experience
5-10
Hi,
I am using VB 2008 and I am new to Windows services, actually building the first service in my career.

Here's my problem, I want my windows service to copy some files from the network drive to C drive (local disk). My service is configured as 'Local System' account and as this type of account can not access network resources I need to know how can I do this. I read few posts on the Internet and found that I can use Windows API or WMI or .Net techniques like 'Impersonate user'. I do not want to use a system tray application etc as user's have control over it.

I don't want the service to be running under user account as I think there would be problems if the user changes his/her password in future. I also do not know password of each user so I think I may have difficulties in Impersonating the users.

Also I am not sure of the UNC path of the network drives as the users are located in different offices. All that I know is the path to folder from where the files need to be copied for example 'J:\Application Files\MyApp\'

Can you please suggest a way through.

Thanks in advance,
Pranav
PN-MH, India
 
If you don't know the location that the files get copied from then how can you possibly copy them without user interaction? If we're talking about the same network all the time then the UNC path is never going to change. Different users may map the folder to different local paths but the UNC path is absolute so will be the same from every workstation.
 
Don't configure the service to run as local system, and don't impersonate a human user.

What you need to do is to create a "Machine Id": an account specifically designed for just your service. For example: svcacct_userbu This account should have READ ONLY access to the directories it needs to copy from, and write access to the location on the server it is going to save the files to. It should be a non-interactive account ( meaning no one can log into you server and use that account. ) and finally - a password that never expires.

Configure the service to run as svcacct_userbu -- it will be able to do what it was programmed to do, and nothing else.
 
Last edited:
Thanks a lot. This is was my first question on the forum I have received so much valueable advice.

I will try the option suggested by both of you and will let you know the outcome.
Thanks once again.

Pranav
 
Back
Top