Windows 2012 Scheduled Tasks not Working correctly Please help

Windows 2012 R2 Standard 64 Bit Server

I just installed Windows 2012 R2 Server and been moving tasks and functions to the new server.
I have the Web sites working on IIS 8.5 almost ready to move into production

Everything worked on Windows 2003 Servers before no issues. Just support dropping for Windows 2003 soon

Have two DC's to move over but I want to work out everything on this server first.

Two of my tasks do not run properly.  They are listed below.

They both have "RUN WITH HIGHEST PRIVILEGES" checked.
They both have  "Run only when user is logged on" checked.

Both using the domain administrator account which is who is logged on the server.

I have other tasks that run fine on the windows 2012 server.

So far just these two.

Both have a line similar that I think might be the problem  that's is the "COPY" command using the + sign

Not sure why that is because I can run both tasks from a command prompt and the both run correctly

Below are both scripts


@echo off

del c:\util\guestbk.txt
del c:\util\gbk.txt

echo %date% >>c:\util\gbk.txt
echo %time% >>c:\util\gbk.txt

copy "c:\util\gbk.txt" + "C:\Inetpub\wwwroot\cgi-bin\guestbook\counter.txt" guestbk.txt
cd\util

c:\util\febooti\febootimail -from no-reply@mydom.com -to admin@mydom.com -msg "Open attachment for Report" -subj "Guest Book Report" -dontupdate -attach guestbk.txt -smtp 10.1.1.36

exit

Open in new window


@echo off
del c:\util\webhits.txt
del c:\util\sitecnt.txt
del c:\util\wrestcnt.txt

xcopy "C:\Inetpub\wwwroot\counter\logs\home.txt" c:\util
rename c:\util\home.txt sitecnt.txt
echo "Hit Counter" >c:\util\webhits.txt
copy webhits.txt + sitecnt.txt webhits.txt

rem add blank line to webhits.txt file
echo. >>c:\util\webhits.txt

xcopy "C:\Inetpub\wwwroot\counter\logs\wrestling.txt" c:\util
rename C:\util\wrestling.txt wrestcnt.txt
echo "Wrestling Site Hit Counter" >>c:\util\webhits.txt
copy webhits.txt + wrestcnt.txt webhits.txt

cd\util
c:\util\febooti\febootimail -from no-reply@mydom.com -to admin@mydom.com -msg "Open attachment for Report" -subj "Hit Counter Report" -dontupdate -attach webhits.txt -smtp 10.1.1.36

exit

Open in new window



Any ideas or suggestions.

Thanks

Tom
LVL 23
Thomas GrassiSystems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
Can you confirm...
...for the first that the lines before the COPY line do work? i.e.
echo %date% >>c:\util\gbk.txt
echo %time% >>c:\util\gbk.txt

...for the 2nd
Place similar echo lines to the log at various points to try to isolate. Examin the log.
Thomas GrassiSystems AdministratorAuthor Commented:
Yes the work

the file gbk.txt is created each time it runs the contents has the date and time

I did find and option that I changed

Configure for was set for Windows Vista, Windows Server 2008

Changed it to Windows Server 2012 R2

The job runs at 9:30 PM will know in about an hour

Will post results
Thomas GrassiSystems AdministratorAuthor Commented:
Update job ran again with no output of the
Copy statement

Can you post example of the echoes you want me to try

Thanks
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

NVITEnd-user supportCommented:
Reviewing your code.
copy "c:\util\gbk.txt" + "C:\Inetpub\wwwroot\cgi-bin\guestbook\counter.txt" guestbk.txt

Open in new window

copy webhits.txt + wrestcnt.txt webhits.txt

Open in new window

Shouldn't it instead be...
copy guestbk.txt + "c:\util\gbk.txt" + "C:\Inetpub\wwwroot\cgi-bin\guestbook\counter.txt"

Open in new window

copy webhits.txt + wrestcnt.txt

Open in new window

Thomas GrassiSystems AdministratorAuthor Commented:
I thought the copy + was

fileA + FileB  Destination File

I can run the command from a command prompt with no problem it works every time

Just not  from task scheduler

If I run the entire script it works also.

Just something going on when the task scheduler runs it

I have many other scripts running on Windows 2012 and Windows 2008 Servers and they all work

But none have the copy + like these two scripts.

Is there a powershell way to do this maybe that would work better

thoughts
NVITEnd-user supportCommented:
My mistake. You are correct.

For both, try includng the path:
copy "c:\util\gbk.txt" + "C:\Inetpub\wwwroot\cgi-bin\guestbook\counter.txt" guestbk.txt

Open in new window

becomes...
copy "c:\util\gbk.txt" + "C:\Inetpub\wwwroot\cgi-bin\guestbook\counter.txt" c:\util\guestbk.txt

Open in new window


copy webhits.txt + wrestcnt.txt webhits.txt

Open in new window

becomes...
copy c:\util\webhits.txt + c:\util\wrestcnt.txt c:\util\webhits.txt

Open in new window


Alternatively, it looks like all the txt files are created in c:\util. So, add a cd c:\util near the top. That is probably easier and cleaner.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Thomas GrassiSystems AdministratorAuthor Commented:
NVIT

Thanks for your help on this

moving the cd\util to the top of the script did it


Thanks again
NVITEnd-user supportCommented:
I'm glad it worked for you, Thomas.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2012

From novice to tech pro — start learning today.