Sign in to follow this  
Followers 0
steff

Service can't access shared folder

5 posts in this topic

#1 ·  Posted (edited)

Hi gurus,

It's been some days I'm breaking my head on a problem.

I wrote a program which I need to run as a service and write to a shared folder (say z:\share).

Installed with instsrv.exe and srvany.exe and changed the "Log on as" to the domain administrator.

The program periodically copies some local file to the shared folder: I changed the group policy setting to allow read/write to that folder to the domain admin.

If I only run a FileExists over it, it doesnt work.

$sharedFolder="z:\share"
If FileExists($sharedFolder) Then 

...do something...

The strange is, if I run it as a normal program and not as a service, it works well, the shared folder is detected and the file are copied.

Does anybody have any idea on how to solve it with autoit?

Thanks in advance for replies

stefano

Edited by steff

Share this post


Link to post
Share on other sites



If it's running as a service one possibility is that the share isn't ready yet when the service runs (i.e. as soon as Windows starts?). Put some kind of wait time before the script actually gets to work, or put something in there to somehow wait for the share to become available...

Share this post


Link to post
Share on other sites

Two things come to mind:

  • The drive Z: is missing. Shares are mapped to drive letters during logon (at least in our environment). Non interactive users don't get shared drives mapped. A solution would be to use UNC notation like "\\servername\sharename" or AutoIt function "DriveMapAdd"
  • Missing permissions. The service might run under a different account and therefore doesn't have the proper permissions

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I am pretty sure the service run as the "system" account. It doesnt have permissions to the share drive.

I had the same issue long time ago.

Share this post


Link to post
Share on other sites

I think water is right: also my research say only interactive logon can let a user map remote drives, no matter if the service is run by an account who has actual access to those folders.

The easiest way to access remote drives is to use the UNC notation (like "\\servername\sharename" ), and that's what I'm going to do.

Thanks to all replies, guys!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0