Windows Task Scheduler Stops Task but does not terminate script

Hi

As part of an forthcoming upgrade we need to create a duplicate of all our data on our servers.  As to not impact our diffeeriential backups by suddenly increasing the amount of data backed up we wish to schedule a robocopy of the data and back small increments on the run up to the go live.

We have created a simple batch script running robocopy and using windows scheduler have configured the job to only run for 15 mins.  After 15 mins the job terminates but the underlying robocopy process continues to copy the data. In task manager the robocopy process is still running.  Is there a way within our script where we can call robocopy that will enable the task scheduler to terminate all processes called from the script.  Below is copy of our script

Thanks

for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=%%i-%%j-%%k-%%l
  for /f "Tokens=1" %%i in ('time /t') do set tm=-%%i
  set tm=%tm::=-%
  set dtt=%dt%%tm%
  set dt=%dt%

start robocopy "R:\objective\erdmprod\doc" "R:\test" /MIR /SEC /LOG:"R:\Obj7copyrepository.log"

mapisend -u servicetsm@scotland.gsi.gov.uk -p " " -r DLCSPTSMA@scotland.gsi.gov.uk -s "VQ65EDER Objective 7 TestDuplicate Doc Store Copy %dtt%"
GraemeTLAsked:
Who is Participating?
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.

Smart_ManCommented:
do you want just the process to be terminated regardless it have finished or not. maybe in teh middle of a copy ?


i guess as the scheduler work with teh script . then it terminates teh script and not programs that the script have called.

who long the robocopy will take before ti gets back to the script ?

is your script have the extention *.bat

waiting for your reply
0
GraemeTLAuthor Commented:
Hi

Firstly the scriot is .cmd.

If the robocopy was to complete it would take several hours due to the volume of data.  We wish the script to terminate even if it is still copying a file. (this includes the robocopy process)  These would be picked up the
 next run.  In the script the mapisend line can be ignored as in theory this should never be reached.
0
Smart_ManCommented:
i sorta solved a simillar issue coupel days ago. used a tool to combine exe and bat in a new exe file

that will be the process that you will use in the scheduler. it is sorta a tool for automated setup creation so you can have a silent install by making a new exe out of the old exe + parameters.

the tool is IExpress.exe. google it so you can download it.

waiting for your reply if that solves the problem
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

GraemeTLAuthor Commented:
IExpress sounds interesting. It is on the servers already but how do I configure, do I add the cmd file and robocopy.exe into the package and create and schedule?
0
Smart_ManCommented:
yes


waiting for your reply
0
GraemeTLAuthor Commented:
I will test
0
GraemeTLAuthor Commented:
Hi

I have created the package by adding the cmd file and the robocopy.exe.  In the package the install program is configured as the script.

When run the new executable from the task scheduler as before it initiates the robocopy.exe process and does not terminate after the task has stopped.  Below is the SED file from the package. I must be doing something wrong

[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=0
HideExtractAnimation=0
UseLongFileName=1
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=I
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[Strings]
InstallPrompt=
DisplayLicense=
FinishMessage=
TargetName=C:\StorageUpgrade\4. Robocopy\RoboCopyPackage.EXE
FriendlyName=RobocopyDocStore
AppLaunched=robocopy.exe
PostInstallCmd=robocopy.exe
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="Robocopydocstore_test.cmd"
FILE1="robocopy.exe"
[SourceFiles]
SourceFiles0=C:\StorageUpgrade\4. Robocopy\
[SourceFiles0]
%FILE0%=
%FILE1%=
0
Smart_ManCommented:
do you have 2 seperate process running after the solution ?

or one process ?

0
GraemeTLAuthor Commented:
Only one I think. Yes sure it is only 1 the robocopy
0
Smart_ManCommented:
you may want to check with task manager. watch when it starts. and when it is the termination time.

can you try your scheduler with a more simple process , maybe teh notepad to check if the termination works fine.

how long is the response time when you manually terminate the robocop using the task maneger?

waiting for your reply
0
GraemeTLAuthor Commented:
Running the package with only the script starts robocopy also (as expected).  After the scheduled task terminates the robocopy process is still running and updating the directories
0
Smart_ManCommented:
i guess you can just start the robocopy with the

robocopy "R:\objective\erdmprod\doc" "R:\test" /MIR /SEC /LOG:"R:\Obj7copyrepository.log"

as a command like with parameters.  this time the schedule will have no child proccess. and when it is the termination time. it will terminat ethe robocopy.

i do nto see any use for the
for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=%%i-%%j-%%k-%%l
  for /f "Tokens=1" %%i in ('time /t') do set tm=-%%i
  set tm=%tm::=-%
  set dtt=%dt%%tm%
  set dt=%dt%



waiting for your reply
0
GraemeTLAuthor Commented:
No this does not work either.  I suppose running the script in the package like this is just like calling the script alone.  Is there anyway to call the robocopy process independantly and input the parametors in this package.  

 The other part of the script was for the mapisend function to add date stamps and correctly is not needed
0
Smart_ManCommented:
as i thought you do not need a script. just few parameters

well then that is too easy. just goto the normal steps to create the scheduled task.
then after u finish . just open the properties window and paste the line with all parameters there, like this

path:\robocopy "R:\objective\erdmprod\doc" "R:\test" /MIR /SEC /LOG:"R:\Obj7copyrepository.log"

waiting for your reply.
0

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
GraemeTLAuthor Commented:
hi

Apologies but I do not follow your advice above.  What job should i be adding to the scheduled task or does this not matter as I will paste over this info

Thanks
0
GraemeTLAuthor Commented:
So easy when you know.  Should have thought of that. Thanks
0
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 Batch

From novice to tech pro — start learning today.