Skip to end of metadata
Go to start of metadata

Accessing mapped network drives (Windows) from a JobScheduler Job


I'm trying to access a mapped network drive (e.g. X:) from a JobScheduler job. The drive can be accessed from outside JobScheduler but within a Job it doesn't exist.


This behavior is more of a Windows feature than a JobScheduler bug. On Windows JobScheduler runs as a service and services are started by a process which is started very early when the operating system starts up. That happens long before the network drives are mounted, which happens when a user logs on.

In order to access a network drive from JobScheduler, you need to mount it in the JobScheduler process. This can be done in the startup script of JobScheduler. In detail, do the following:

  • Make sure JobScheduler is running as a user that has permission to access the network drive(s) (Check the services configuration to set a different user).

  • Configure a scheduler start script to mount the network drive:

    <scheduler_script name = "mount_drives">
    	<script language="VBScript">
    			Function spooler_init
    				Dim ws, return_code, command
    				command = "net.exe use X: \\server\dir *"
                    'See "net use /?" for more information
                    Set ws = CreateObject("")
    				return_code = command, 0, 1 )
    				Set ws = Nothing
    				If return_code > 0 Then spooler_log.warn("Failed to mount drives: " & return_code)
    				spooler_init = true
    			End Function
  • Put the <script> element into config/scheduler.xml file between the <process_classes> and <http_server> elements.

  • Restart the JobScheduler

Note that this problem might have to do with the moment that the process which starts the services is started. If the environment variables do not yet exist, then they cannot be inherited by the services. See if it changes when you change the user that runs the service.

Write a comment…