dcsimg
File.exists() method is not working as expected while running as part of Windows 2000 Service.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rajesh_Kamisetty
Posted On:   Thursday, July 29, 2004 05:52 PM

The following code displays "true" when run from command line. The same code while running as Win2k Service returns false. Any idea?


			
------------------------------------------------------------
File f = new File("//data4.corp.hmsa.com/restricted/ftp/claims/susptrgr.txt");
if(f.exists()){ System.out.println("true"); }
------------------------------------------------------------

Re: File.exists() method is not working as expected while running as part of Windows 2000 Service.

Posted By:   Steve_Donkin  
Posted On:   Monday, August 16, 2004 08:00 AM

The reason is Java security as your service runs as the Windows SYSTEM user. I'm not sure how to get round this for a URI. I had a similar issue with virtual drives, by creating the drive mapping as system (using net use from cmd) it solved my issue.

Re: File.exists() method is not working as expected while running as part of Windows 2000 Service.

Posted By:   Rajesh_Kamisetty  
Posted On:   Friday, July 30, 2004 01:26 PM

I got the answer. It's simple (as always). My program as windows 2000 service, by default runs under "LocalSystem" user. I had changed that to my windows login-id (PL1234) which has rights to the remote Claims folder on data4.corp.hmsa.com. It runs fine now.

Though I had suspected this before. But then I thought File.exists() method throws SecurityException. Which doesn't happen if there is no SecurityManager according to javadoc of exists method.

bye!
Rajesh K
About | Sitemap | Contact