• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Map drive access through Java Application running as a service

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am facing a typical problem for which I would like to seek some help.
I have created one Map drive in my system for some shared folder in the network. Now what i require is to read some file at this location.

For this purpose I created one Java application that reads the file from the map drive location. The program is working fine when i run it as a java process in windows XP OS.

But when i run the same application as a Windows Service, the application is unable to detect the map drive and is unable to read the file even though the map drive is accessible in windows system.

For this problem I searched a lot and found that Windows don't allow to access Map drives if application is running as a SERVICE. ie Map drives are only accessible if the application runs as a PROCESS. But my limitation is that I can not run my application as a process.

Thus I would be thankful if someone helps me out with some solution as to how would I be able to access the map drive through my application which runs as Windows SERVICE. I have read some where that it can be made possible by creating a Java Service Wrapper, but I don't knw how to do that !!!

I have even tried to access the file using UNC convention, but UNC fails for the n/w share folder which requires password to open them. Thus UNC convention is also not fully working for my application.

Thus can anyone help to create a Java Service Wrapper or give some example to solve the problem of accessing UNC path for the folder that requires password to open it.

In short, can anyone help me out with some way of accessing MAP Drive / network shared folder when application is running as a Windows SERVICE.

I am using Windows XP on my system.

Thanks in advance
Saurabh
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, you can't do it. You need to use the machine name mapping ie \\machine\share\directory\file.ext You will also need to make sure tha the user the service runs as has access to the share, or you may need to change the service user.

Dave
 
Saurabh Vyas
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks David.

My problem is solved by accessing the n/w file using UNC Path. Just for others information, I would like to explain here as to how my problem was solved.

Now UNC was giving problem, through an application that runs as Windows Service, for the n/w folder that requires password to open it. Thus to solve this I changed my service user as suggested by David. My application was always being installed for an Admin User, so i changed the "Log On As" type of my service to ".\Administrator". Thus it started to work fine.

To change the service user, follows the below mentioned steps:

1) Start your application that runs as a windows service.
2) Go to Start -> Setting -> Control Panel -> Administrative Tools -> Services.
3) Search for your application service in that list. It would be listed by default as "Local System".
4) Now open properties for that service and goto "Log On" tab.
5) Change selection to "This Account" and browse the user account that you want to support for your service. In my case i selected Administrator.
6) Enter the appropriate password and apply the changes.
7) You may require to restart your Service to get the changes applied.

Thats it.... You are done.

Now your application would be able to access UNC Path for all n/w folders.



Regards
Saurabh
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Saurabh",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with display names get deleted, often without warning

thanks,
Dave
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to continue my previous warning, it appears that this was your initial display name, you changed to something invalid after one warning, then changed it to a valid display name after your second warning, and now you have decided to change it back to the initial, invalid display name.

Please consider this your third and final warning. We require your display name to conform to the rules or I will be closing your account

thanks,
Dave.
 
Saurabh Vyas
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok the Display name is now changed.
 
reply
    Bookmark Topic Watch Topic
  • New Topic