This is actually on a Windows 2003 server but I didn't see it among the
options.

I've created a batch file on server A to generate a report and copy it to a
shared drive on server B. When I log onto server A and run the batch file it
works; when I use the task scheduler to run the batch it fails. A coworker
suggested using the unc path rather than the mapped drive letter designation
but that didn't help - all that did was generate a "CMD does not support UNC
paths as current directories" error message.

I have a hunch that the problem is because the shared drive is not
recognized unless the user physically logs onto the box. Is that the case and
is there a way to work around this?

Re: scheduled task can not access shared drive by Pegasus

Pegasus
Sat May 03 22:35:12 PDT 2008


"powdered_toast_man" <powderedtoastman@discussions.microsoft.com> wrote in
message news:81D01B94-2218-45CA-99C3-8E2883898004@microsoft.com...
> This is actually on a Windows 2003 server but I didn't see it among the
> options.
>
> I've created a batch file on server A to generate a report and copy it to
> a
> shared drive on server B. When I log onto server A and run the batch file
> it
> works; when I use the task scheduler to run the batch it fails. A coworker
> suggested using the unc path rather than the mapped drive letter
> designation
> but that didn't help - all that did was generate a "CMD does not support
> UNC
> paths as current directories" error message.
>
> I have a hunch that the problem is because the shared drive is not
> recognized unless the user physically logs onto the box. Is that the case
> and
> is there a way to work around this?

Let's have a look at your batch file!

What account do you use for the scheduled task? Does it have access
to the shared resource?

About newsgroups: There are several with the word "Server" in it, e.g.
"windows.server.general".



Re: scheduled task can not access shared drive by powderedtoastman

powderedtoastman
Sun May 04 06:14:01 PDT 2008



"Pegasus (MVP)" wrote:

>
> "powdered_toast_man" <powderedtoastman@discussions.microsoft.com> wrote in
> message news:81D01B94-2218-45CA-99C3-8E2883898004@microsoft.com...
> > This is actually on a Windows 2003 server but I didn't see it among the
> > options.
> >
> > I've created a batch file on server A to generate a report and copy it to
> > a
> > shared drive on server B. When I log onto server A and run the batch file
> > it
> > works; when I use the task scheduler to run the batch it fails. A coworker
> > suggested using the unc path rather than the mapped drive letter
> > designation
> > but that didn't help - all that did was generate a "CMD does not support
> > UNC
> > paths as current directories" error message.
> >
> > I have a hunch that the problem is because the shared drive is not
> > recognized unless the user physically logs onto the box. Is that the case
> > and
> > is there a way to work around this?
>
> Let's have a look at your batch file!
>
> What account do you use for the scheduled task? Does it have access
> to the shared resource?
>
> About newsgroups: There are several with the word "Server" in it, e.g.
> "windows.server.general".
>
>
A domain level servce account is running the task; it does have access to
the resource. Again, when I actually remote desktop onto the server with the
service account id and run the batch file it works fine - it only fails as a
scheduled task. Perhaps I don't fully understand the difference between
physically logging onto a server and the way task scheduler "logs on" to run
the task but something tells me that's the difference and reason for failure.

As far as the batch file itself, it's very simple:
copy "C:\reports\daily_report" "Z:\transferred reports\daily_report"
Where "Z" is the mapped shared drive. As mentioned I also tried it with the
unc path of "\\servername\share\transferred reports\daily_report" but that
didn't do the trick either.

Re: scheduled task can not access shared drive by Pegasus

Pegasus
Sun May 04 07:31:46 PDT 2008


"powdered_toast_man" <powderedtoastman@discussions.microsoft.com> wrote in
message news:A7938743-8FE2-4ED4-9A1F-EBC15CFB8574@microsoft.com...
>
>
> "Pegasus (MVP)" wrote:
>
>>
>> "powdered_toast_man" <powderedtoastman@discussions.microsoft.com> wrote
>> in
>> message news:81D01B94-2218-45CA-99C3-8E2883898004@microsoft.com...
>> > This is actually on a Windows 2003 server but I didn't see it among the
>> > options.
>> >
>> > I've created a batch file on server A to generate a report and copy it
>> > to
>> > a
>> > shared drive on server B. When I log onto server A and run the batch
>> > file
>> > it
>> > works; when I use the task scheduler to run the batch it fails. A
>> > coworker
>> > suggested using the unc path rather than the mapped drive letter
>> > designation
>> > but that didn't help - all that did was generate a "CMD does not
>> > support
>> > UNC
>> > paths as current directories" error message.
>> >
>> > I have a hunch that the problem is because the shared drive is not
>> > recognized unless the user physically logs onto the box. Is that the
>> > case
>> > and
>> > is there a way to work around this?
>>
>> Let's have a look at your batch file!
>>
>> What account do you use for the scheduled task? Does it have access
>> to the shared resource?
>>
>> About newsgroups: There are several with the word "Server" in it, e.g.
>> "windows.server.general".
>>
>>
> A domain level servce account is running the task; it does have access to
> the resource. Again, when I actually remote desktop onto the server with
> the
> service account id and run the batch file it works fine - it only fails as
> a
> scheduled task. Perhaps I don't fully understand the difference between
> physically logging onto a server and the way task scheduler "logs on" to
> run
> the task but something tells me that's the difference and reason for
> failure.
>
> As far as the batch file itself, it's very simple:
> copy "C:\reports\daily_report" "Z:\transferred reports\daily_report"
> Where "Z" is the mapped shared drive. As mentioned I also tried it with
> the
> unc path of "\\servername\share\transferred reports\daily_report" but that
> didn't do the trick either.

Your batch file has a couple of problems:
- Drive Z: is unlikely to exist. You MUST use UNC names.
- If the file exists in the target folder then the batch file may hang,
waiting for your comfirmation to overwrite it.

Try this instead:
1. @echo off
2. set TargetDir=\\Server\Share\transferred reports
3.
4. echo Start %date% %time% %UserName% >> c:\test.log
5. dir "%TargetDir%" 1>>c:\test.log 2>>&1
6. copy /y "C:\reports\daily_report" "%TargetDir%" 1>>c:\test.log 2>>&1
7. echo End %date% %time% >> c:\test.log
8. echo. >> c:\test.log

Watch out for wrapped lines! After running the job through
the scheduler, examine c:\test.log and post it if the problem
is not perfectly obvious. By the way - is "daily_report" a file
or a folder? If it is a folder then the code should look like so:
1. @echo off
2. set TargetDir=\\Server\Share\transferred reports
3.
4. echo Start %date% %time% %UserName% >> c:\test.log
5. dir "%TargetDir% 1>>c:\test.log 2>>&1
6. xcopy /y "C:\reports\daily_report\*.*" "%TargetDir%\daily_report\"
1>>c:\test.log 2>>&1
7. echo End %date% %time% >> c:\test.log
8. echo. >> c:\test.log



Re: scheduled task can not access shared drive by Dave

Dave
Sun May 04 15:01:56 PDT 2008

Also don't forget if the job connects to another machine you may need to add
the user/ group 'logon as batch job' rights (server side). Control
Panel|Admin Tools|Local Security Policy\Local Policies\User Rights
Assignments
"Log on as a batch job"


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


Re: scheduled task can not access shared drive by powderedtoastman

powderedtoastman
Sun May 04 17:09:00 PDT 2008



"Dave Patrick" wrote:

> Also don't forget if the job connects to another machine you may need to add
> the user/ group 'logon as batch job' rights (server side). Control
> Panel|Admin Tools|Local Security Policy\Local Policies\User Rights
> Assignments
> "Log on as a batch job"
>
>
> --
>
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft Certified Professional
> Microsoft MVP [Windows]
> http://www.microsoft.com/protect
>
Thanks to you both. I actually got it to work - feel a bit stupid about
this but noticed that I had left the "$" out of the unc path (duh.) I'll be
back if that wasn't the problem (I'll know tomorrow morning as these are
scheduled to run overnight.)

Re: scheduled task can not access shared drive by Pegasus

Pegasus
Sun May 04 22:06:52 PDT 2008


"powdered_toast_man" <powderedtoastman@discussions.microsoft.com> wrote in
message news:0CF63EA6-765B-4F6E-A6A6-9C840410DB73@microsoft.com...
>
>
> "Dave Patrick" wrote:
>
>> Also don't forget if the job connects to another machine you may need to
>> add
>> the user/ group 'logon as batch job' rights (server side). Control
>> Panel|Admin Tools|Local Security Policy\Local Policies\User Rights
>> Assignments
>> "Log on as a batch job"
>>
>>
>> --
>>
>> Regards,
>>
>> Dave Patrick ....Please no email replies - reply in newsgroup.
>> Microsoft Certified Professional
>> Microsoft MVP [Windows]
>> http://www.microsoft.com/protect
>>
> Thanks to you both. I actually got it to work - feel a bit stupid about
> this but noticed that I had left the "$" out of the unc path (duh.) I'll
> be
> back if that wasn't the problem (I'll know tomorrow morning as these are
> scheduled to run overnight.)

Thanks for the feedback. It actually leaves me mystified because
I cannot reconcile it with this phrase from your initial post: "When
I log onto server A and run the batch file it works; when I use the
task scheduler to run the batch it fails."



Re: scheduled task can not access shared drive by Bob

Bob
Mon May 05 06:52:49 PDT 2008



Pegasus (MVP) wrote:

> "powdered_toast_man" <powderedtoastman@discussions.microsoft.com> wrote in
> message news:0CF63EA6-765B-4F6E-A6A6-9C840410DB73@microsoft.com...
>
>>
>>"Dave Patrick" wrote:
>>
>>
>>>Also don't forget if the job connects to another machine you may need to
>>>add
>>>the user/ group 'logon as batch job' rights (server side). Control
>>>Panel|Admin Tools|Local Security Policy\Local Policies\User Rights
>>>Assignments
>>>"Log on as a batch job"
>>>
>>>
>>>--
>>>
>>>Regards,
>>>
>>>Dave Patrick ....Please no email replies - reply in newsgroup.
>>>Microsoft Certified Professional
>>>Microsoft MVP [Windows]
>>>http://www.microsoft.com/protect
>>>
>>
>>Thanks to you both. I actually got it to work - feel a bit stupid about
>>this but noticed that I had left the "$" out of the unc path (duh.) I'll
>>be
>>back if that wasn't the problem (I'll know tomorrow morning as these are
>>scheduled to run overnight.)
>
>
> Thanks for the feedback. It actually leaves me mystified because
> I cannot reconcile it with this phrase from your initial post: "When
> I log onto server A and run the batch file it works; when I use the
> task scheduler to run the batch it fails."
>
>
Originally the batch worked when he logged in because his profile had
"Z" mapped. After he changed it to UNC it still didn't work in task
scheduler because of the missing "$" in the path.