Jump to content

Service can't access shared folder


Recommended Posts

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
Link to comment
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...

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...