Reputation: 8593
We have a Buffalo NAS drive as a backup drive.
And when we map this drive as B:\
, our backup application seems to understand this and run as an application.
But when run as a service, it does not recognize the mapping and crashes.
I tried giving the path as \\\192.168.x.x\Backups\
as the backup path, the service runs but then a lot of submodules fail because it sees the \\\
as a escape character.
What is the workaround so that the windows service can see the mapped drive.
I am trying to run zip.exe via a CreateProcess()
;
""C:\Users\jvenkatraj\Documents\SQLite\Debug\zip.exe" -9 -q -g -u "\\\192.168.123.60\Backup\store\location1\50\f2\25\43\d8\88\b9\68\49\8d\2b\d0\08\9e\7e\df\z.zip" "\\\192.168.123.60\Backup\store\temp\SPD405.tmp\file_contents""
The backslashes are messing with the quotes. And it is a WCHAR type, and I can't change it to any other type, else I will have to redefine this elsewhere as well. How many backslashes should I use?
Upvotes: 1
Views: 839
Reputation: 36328
You can map a network drive inside the service itself using the WNetAddConnection2 API function.
Upvotes: 1
Reputation: 15313
The easiest way to do this would probably be to access the network path
string path = @"\\192.168.x.x\Backups\";
Another thing you have to make sure of is that the service has access to this path. If your service is logged in as a user that does NOT have access you have to change logon credentials of the service to a user/domain account that does have access to this path.
Upvotes: 0
Reputation: 52137
Try running your service under a user that "sees" the network, such as the "Network Service" user or even as the "human" user that mapped the network drive.
Upvotes: 0
Reputation: 36328
Create a symbolic link somewhere to the NAS share:
mklink /D c:\nas-backups \\192.168.x.x\Backups
and point your backup application to c:\nas-backups\etc
.
Upvotes: 1