 |
|
 |
Hi
Thanks for your this post. I have a scenario like my windows service will run under the local system only but need to access the map drive or the UNC PATH.The map path credential are different from my NT Credential means I login to my system with a NT USERID and Password but to create a MAP drive i use different USERID and Password.
Please help me this to access the uncpath or the map drive with your program or dll.
I am using vb.net1.1
Thanks In Advance
Raman Sharma
|
|
|
|
 |
|
 |
Where do i have to put the properties.xml file?
Thanks!
|
|
|
|
 |
|
 |
Hi,
Below my code use in windows service, but result is always false.
HelperAPI.NetworkHelper networkhelper = null;
networkhelper = HelperAPI.NetworkHelper.GetInstance();
bool result;
result = networkhelper.WNetAddConnection(@"M:", "\\network_directory", "login", "password", true);
There is something more to do ?
Thanks
|
|
|
|
 |
|
|
 |
|
 |
I can't get the Service to start.
Windows XP SP2
I loaded the source into VS, built HelperAPI.dll
Added HelperAPI.dll to the Demo as a reference and built everything.
Installed the service with c:\sc create binpath= C:\HelperAPI_Demo\bin\Release\HelperAPITest.exe
-Properties file is located in release folder
If I just double click the file, it maps the drive perfectly.
What am I doing wrong?
Here is the error I get when trying to start the service
=================================================================================
The HelperAPITest service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.
Timeout (30000 milliseconds) waiting for the HelperAPITest service to connect.
=================================================================================
|
|
|
|
 |
|
 |
Resolved the issue.
Found it was looking for Properties.xml in Windows\System32
Also thats were the log is output to.
Few things about this service though, unless you run the service as a different user then System, it does not seem like this is a viable solution.
Additionally, while the service does not actually show it as staretd, and complains about a timeout, the drive is actually mapped, can only been seen under (Tool/Map Drive) --the lack of accessibility makes this solution someone unusable.
Other ways of implementing something to this effect can be done via program call PrimalScript, which has the capability to package a vbscript as an .exe
Then you can just creat the service
c:\sc create "Map Drive Service" binpath= C:\ConvertedVbScript.exe
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%comspec% /c" & "net use T: \\computer\C$ /user:computer\user password/persistent:Yes"
WScript.Quit
Note: This drive can only be disconnected by LocalSystem, so you would need to have the same type of exe to disconnect..
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%comspec% /c" & "net use /delete T: /y"
WScript.Quit
One other thing, you will notice the drive is named "Disconnected Network Drive" or something to that effect, I am still looking for a way to automate the rename of this, to programatically do it in vbsdript requires a session object, to which you don't have as LocalSystem :P
|
|
|
|
 |
|
 |
Hi Suresh,
You say:
"if a service needs to access files on the network, it generally needs to be configured to run as a domain user with access to those files. "
Does this apply only when the folder is on the network NOT mapped as logical drive? I'm asking this since I have been unable to access a folder ALREADY mapped on my computer ( logical drive Z: ) is this possible? Will you please let me know what I need to do?
I appreciate your help.
Thanks.
Edwin.
|
|
|
|
 |
|
 |
Hi Edwin,
Under which user credential the logical drive has been mapped in to your computer? If the folder has been mapped on using windows user(i.e logged in user), then windows service can't get the information. Because each user will have a separate home directory and you can't get the mapped folder of another user connected.
So if you want to read mapped folder from windows service, then you have to connect the folder from windows service itself.
Assume you have windows service and want to read the mapped folder, then while starting the windows service program itself, just map the folder as a logical folder to your computer.
Hope i have explained. Reply me if you want more info.
Thank,
Suresh M
Suresh M
|
|
|
|
 |
|
 |
Hi Suresh,
Thanks you so much for your reply.
Yes, the logical drive has been mapped by using a windows user. A question: Is the windows service definitely unable to access this folder even if that windows service is running under the same user account as the user who mapped the folder mentioned? (I'm trying the windows service under this scenario)
Thanks for help.
~Edwin
|
|
|
|
 |
|
 |
Hi Suresh,
I read your article and downloaded your source too. i tried to connect a folder in network through windowservice its not working.
i'm getting error "The network name cannot be found".
i given input as follows
NetworkHelper networkhelper;
networkhelper = NetworkHelper.GetInstance ();
bool result;
result = networkhelper.WNetAddConnection(@"K:", @"\192.168.55.32\HPSServiceLog", "administrator", "admin", false);
DirectoryInfo dirInfo = new DirectoryInfo(@"K:\");
FileInfo[] files = dirInfo.GetFiles();
After this i mapped the "\192.168.55.32\HPSServiceLog" network drive in my machine and tried. I'm not able to connect and get files.
Can you help me to solve this...
S. Ramkumar
|
|
|
|
 |
|
|
 |
|
 |
i have seen cnetworkdrive. its really good. but if we need to connnect the drive from windows service, then that time we need to configure the settings some where like XML or some config file but in cnetworkdrive, we have to use gui. in windows services, however its not possible.
thanks
cool code dude
suresh m
|
|
|
|
 |
|
 |
Hi,
i'm using your code, to map a network drive from a windows service and i always get an 'access denied' exception. i'm starting to believe, that windows services don't have rights to access the network. if anyone has a solution for this please write something!
Big thanks in advance!
Csaba
|
|
|
|
 |
|
 |
hi,
just try to run the service using your adminstrator account. you can change this using services.msc
suresh m
|
|
|
|
 |
|
 |
I could not compile the project as dependencies were not found. please upload all project files..
thanks in anticipation.
harry
|
|
|
|
 |
|
 |
Hi,
Sorry for my late response.
There is no dependecies for this project. "***_Src.zip" contains the source code and "****_demo.zip" contains the sample project.
Thats it.
suresh m
|
|
|
|
 |
|
 |
Hi,
I really need this feature but I've running a lot of time your code and it seams to work only from your test application (console or windows).
From Windows service is working too but, it doesn't mapp the drive on
actual user session (desktop), I've seen it as map drive (win explorer->Tools-> map network drive)
but I cannot see it as map (drive) in win explorer tree and I cannot access it.
Did I miss something?
Thanks,
|
|
|
|
 |
|
 |
Mapped drives only apply to current login session of the user that executed the code, so the drive will only be mapped to the user account that the service runs under.
Even if you run the service under your account, I don't think it will be visible to you in explorer because the service runs under a different login session.
|
|
|
|
 |
|
 |
By default Windows services are run under the virtual user "LocalSystem" that has ultimate administrative rights on the system. Since this is not a real user, there is no home directory for this user.
And also you cant find the mapped drive which has been mapped to your system thru this account.
cool
suresh m
|
|
|
|
 |