WIN 7 ili 10 i BATCH skripta (i Task Sheduler)

Šta koristiti za kopiranje samo novoizmenjenih fajlova sa jednog na drugi folder (drugi je mountovan i nalazi se na backup lokaciji).
Probala sam xcopy ali ima bagova, a ima i ograničenja.
Robocopy je bolji izbor.

Dakle moj batch fajl test1.bat :
echo oooooooooooooooooooooooooooo >> kopiranje.txt
robocopy “D:\Moja Dokumenta\Testiranje” Z:\TEST test*.txt /e /xo /tee /log+:kopiranje.txt
echo oooooooooooooooooooooooooooo >> kopiranje.txt

:: /xo – copy only newer files
:: /e – copy folders recursively
:: /tee – log output to CLI
:: /log+ – dodaje na vec postojeci log bez prepisivanja

I kako poslati mail posle kraja zadatka (isto u test1.bat fajlu), zajedno sa log fajlom :
:: slanje mail poruke
:: slanje mail poruke
powershell -ExecutionPolicy ByPass -Command Send-MailMessage ^
-SmtpServer 10.10.10.10 ^
-To velda.midanovic@moj.domen ^
-From velda.midanovic@moj.domen ^
-Subject testXXXXX ^
-Body testXXXXX ^
-Attachments ‘D:\Moja Dokumenta\Testiranje\kopiranjeXXXXX.txt’

Napomena : source folder MORA da se navede pod duplim navodnicima, jer drugačije neće da radi kroz Task Sheduler (radi kada se skripta pušta ručno).

Problem nastaje kada pokušam da ga stavim u WIN 10 Task Sheduler da se obavlja automatski, pošto mi to ne uspeva.
Evo šta sve treba podesiti (dobar link) :
From Windows Task Scheduler on the job Properties :
1. General tab :
Uncheck Run only when user is logged on
Check Run whether user is logged on or not
Check Run with the highest privileges
2. Conditions tab :
Check Wake the computer to run this task
3. Actions tab, click Edit, and ensure that the “Start in” is set with NO double quote marks around the full path pointing where the batch script is located WITHOUT a final backslash “\”.

Zakođe iz misterioznih razloga kada se skripta pušta kroz Task Sheduler (a ne ručno) NE PREPOZNAJE mapirane diskove, tako da ih moramo navesti sa punom putanjom : \\storage\folder1\folder2\folder3\folder4.

Razni izlazi iz robocopy komande
“Tweaked” A Tweaked file is defined to be one that exists in both the source and destination, with identical size and timestamp, but different attribute settings.
“Lonely” A “lonely” file is present in source but not destination; excluding lonely will prevent any new files being added to the destination.
“Extra” An “extra” file is present in destination but not source; excluding extras will prevent any deletions from the destination. “Extras” will be removed if you’re using options like PURGE and MIR.
“New Dir” represents a folder that existed on the source but not in the target, and “Extra Dir” represents a folder that existed in the target that wasn’t in the source.
“New File” and “Extra File” are the same thing, only for files. 🙂

Moguće greške
Ako pokušate da definišete zadatak u Task Sheduler-u, i javi vam se greška :

To se rešava dodeljivanjem adekvatnih prava :

Comments are closed.