Date: Fri, 29 Mar 2024 10:23:03 +0000 (UTC) Message-ID: <2039920215.12743.1711707783159@change.sos-berlin.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_12742_1385297907.1711707783159" ------=_Part_12742_1385297907.1711707783159 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Question:
I'm trying to access a mapped network drive (e.g. X:) from a JobSchedule= r job. The drive can be accessed from outside JobScheduler but within a Job= it doesn't exist.
Answer:
This behavior is more of a Windows feature than a JobScheduler bug. On W= indows JobScheduler runs as a service and services are started by a process= which is started very early when the operating system starts up. That happ= ens long before the network drives are mounted, which happens when a user l= ogs 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 J= obScheduler. In detail, do the following:
Make sure JobScheduler is running as a user that has permission to a= ccess the network drive(s) (Check the services configuration to set a diffe= rent user).
Configure a scheduler start script to mount the network drive:
<sched= uler_script name =3D "mount_drives"> =09<script language=3D"VBScript"> =09=09<![CDATA[ =09=09=09Function spooler_init =09=09=09=09Dim ws, return_code, command =09=09=09=09command =3D "net.exe use X: \\server\dir *" 'See "net use /?" for more information Set ws =3D CreateObject("Wscript.shell") =09=09=09=09return_code =3D ws.run( command, 0, 1 ) =09=09=09=09Set ws =3D Nothing =09=09=09=09If return_code > 0 Then spooler_log.warn("Failed to mount dr= ives: " & return_code) =09=09=09=09spooler_init =3D true =09=09=09End Function =09=09]]> =09</script> </scheduler_script>
Put the <script>
element into config/schedu=
ler.xml
file between the <process_classes>
and
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.