YonZ Posted September 6, 2006 Posted September 6, 2006 Hello I'm just wondering if anyone have a sample on how to create a script who will do a filecopy (mirroring) from one fileshare to a local disk, it has to be a true mirroring, so old files will be deleted on the local disk... Just as i would do with "Robocopy /MIR" or is it possible to make a "wrapper" around robocopy to do this? This script will then be scheduled to run hourly or more often.... with some error checks (if the PC is not on the network it will not compline, just try again later... Thanx YonZ
AceLoc Posted September 6, 2006 Posted September 6, 2006 HelloI'm just wondering if anyone have a sample on how to create a script who will do a filecopy (mirroring) from one fileshare to a local disk, it has to be a true mirroring, so old files will be deleted on the local disk...Just as i would do with "Robocopy /MIR" or is it possible to make a "wrapper" around robocopy to do this?This script will then be scheduled to run hourly or more often.... with some error checks (if the PC is not on the network it will not compline, just try again later... ThanxYonZhttp://www.autoitscript.com/forum/index.ph...ode=adv&f=2 [quote name='AceLoc']I gots new sunglasses there cool.[/quote]
dabus Posted September 6, 2006 Posted September 6, 2006 http://www.autoitscript.com/forum/index.ph...amp;hl=robocopy
YonZ Posted September 7, 2006 Author Posted September 7, 2006 http://www.autoitscript.com/forum/index.ph...amp;hl=robocopy I don't want any GUI, max simple icon in the Taskbar, showing status... running or waiting or no connection to fileserver....
MHz Posted September 7, 2006 Posted September 7, 2006 I don't want any GUI, max simple icon in the Taskbar, showing status... running or waiting or no connection to fileserver....Do you want a side order of fries to go with that also?
Moderators SmOke_N Posted September 7, 2006 Moderators Posted September 7, 2006 Do you want a side order of fries to go with that also? MHz woke up with Jokes Today!! Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
YonZ Posted September 7, 2006 Author Posted September 7, 2006 MHz woke up with Jokes Today!! Slow down guy's, I'm only trying to do my work.... as I'm not a Scripting Guru, I need to ask!I thought gus like you liked to show us how clever you are? I have created a script for this, but it does not look nice, I did want to use varibales to make the runwait part look better, as I do in my Batch scripts... But I can find out how to do it correctly.Dim $options, $dest, $logg, $source, $test, $what, $val, $prog, $val2$options='/R:15 /W:53 /TBD /RH:0715-2359 /MOT:39'$logg='/LOG+:C:\temp\_katastrofe_dok3.log /NFL /NDL';~ :: /R:n :: number of Retries;~ :: /W:n :: Wait time between retrie;~ :: /RH:hhmm-hhmm :: Run Hours - times when new copies may be started.;~ :: /MOT:n :: MOnitor source; run again in m minutes Time, if changed.;~ :: /LOG :: Output log file;~ :: /NFL :: No file logging;~ :: /NDL :: No dir logging $what='/COPYALL /B /SEC /MIR';~ :: /COPYALL :: COPY ALL file info;~ :: /B :: copy files in Backup mode. ;~ :: /SEC :: copy files with SECurity;~ :: /MIR :: Mirror a directory tree $source='"\\global-data-server\global\work\KA"'$dest=' c:\test ';~ name of the exe file$prog='C:\Script\robocopy.exe';~ I wanted to combining all varibles in to one, but it does not work!; $runner = & $prog & $source & $dest& $what & $options & $logg; then I wanted to run it like this... and that does not work too...;~ RunWait(@ComSpec & $runner, 'c:\script', @SW_HIDE); This line does work.RunWait( 'c:\script\robocopy "\\global-data-server\global\work\KA" c:\test /COPYALL /B /SEC /MIR /R:15 /W:53 /TBD /RH:0715-2359 /MOT:39 /LOG+:C:\temp\_katastrofe_dok2.log /NFL /NDL', 'c:\script', @SW_HIDE)
lod3n Posted September 7, 2006 Posted September 7, 2006 Try clipput($runner), and then paste that line into the command prompt, and see what you get. It looks like you're generating some invalid switches for RoboCopy. Here's a hint: +" "+ [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
MHz Posted September 7, 2006 Posted September 7, 2006 (edited) This may do your commandline. I am counting that you will not have spaces in your log file. $prog = 'c:\script\robocopy' $source = '\\global-data-server\global\work\KA' $dest = 'c:\test' $what = '/COPYALL /B /SEC /MIR' $options = '/R:15 /W:53 /TBD /RH:0715-2359 /MOT:39' $logg = '/LOG+:C:\temp\_katastrofe_dok2.log /NFL /NDL' RunWait(@ComSpec & ' /c "' & $prog & '" "' & $source & '" "' & $dest & '" ' & $what & ' ' & $options & ' ' & $logg, 'c:\script', @SW_HIDE) Edit: Added & just before $logg as issue mentioned below. Edited September 8, 2006 by MHz
YonZ Posted September 8, 2006 Author Posted September 8, 2006 This may do your commandline. I am counting that you will not have spaces in your log file. $prog = 'c:\script\robocopy' $source = '\\global-data-server\global\work\KA' $dest = 'c:\test' $what = '/COPYALL /B /SEC /MIR' $options = '/R:15 /W:53 /TBD /RH:0715-2359 /MOT:39' $logg = '/LOG+:C:\temp\_katastrofe_dok2.log /NFL /NDL' RunWait(@ComSpec & ' /c "' & $prog & '" "' & $source & '" "' & $dest & '" ' & $what & ' ' & $options & ' ' $logg, 'c:\script', @SW_HIDE) I did try your code... but... I got Error... This expression stuff is to complicated for me... I just can't figure out how to do it... Stupid, yes I think so.. :"> +> Starting AutoIt3Wrapper v.1.7.1 >Running:(3.2.0.1):C:\Program Files\AutoIt3\autoit3.exe "C:\script\katastrofe.au3" C:\script\katastrofe.au3 (34) : ==> Error in expression.: RunWait(@ComSpec & ' /c "' & $prog & '" "' & $source & '" "' & $dest & '" ' & $what & ' ' & $options & ' ' $logg, 'c:\script', @SW_HIDE) RunWait(^ ERROR +>AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 1.317
MHz Posted September 8, 2006 Posted September 8, 2006 Ah, left out an "&", my mistake, sorry. Corrected above rather then reposting code. Au3Check says it is fine now.
YonZ Posted September 8, 2006 Author Posted September 8, 2006 (edited) It always surprise me how usefull it is to Read The F.... Manual... It works now! Dim $options, $dest, $logg, $source, $test, $what, $val, $prog, $val2, $runner $options = '/R:15 /W:53 /TBD /RH:0715-2359 /MOT:39' $logg = '/LOG+:C:\temp\_katastrofe_dok2.log /NFL /NDL' $what = '/COPYALL /B /SEC /MIR' $source = 'c:\temp' $dest = 'c:\test' $prog = 'c:\script\robocopy' $runner = $prog & ' "' & $source & '" "' & $dest & '" ' & $what & ' ' & $options & ' ' & $logg RunWait( $runner, 'c:\script', @SW_HIDE) Thanx for the help!! Now I can add all the fancy error checks and stuff... with help from the forum of course.... Edited September 8, 2006 by YonZ
YonZ Posted September 9, 2006 Author Posted September 9, 2006 Thanx for the help!! Now I can add all the fancy error checks and stuff... with help from the forum of course.... And here it is... working with all the fancy stuff.... And what Will this script do? Well It use robocopy to Synchronize data between 2 share, and I will then Schedule this to run every hour. This Script read robocopy settings from the Robo-Sync.ini file, and user can display result after the run is wanted. I use second Destination, "USB Drive", Where I first run the Synchronization between FileServer end the PC, and then from the Destenation Source (Local Source) to the USB Drive, But I always check if the Drive is up before any run, as this will be running on laptops, who is not always on the network.. Nb. This is my first AutoIT Script, so donæt say at I did not warn you! expandcollapse popup#include <file.au3> Global $robocopy, $options, $dest, $logg, $source, $what, $runner, $prog_source, $LogFile, $var, $err, $ini, $usbdest, $usbrunner, $dractive $ini = @ScriptDir & '\' & 'Robo-Sync.ini' $LogFile = @TempDir & '\_Robo-Sync-Run.log' If FileExists(@TempDir & '\_Robo-Sync-Run.log') Then FileDelete(@TempDir & '\_Robo-Sync-Run.log') EndIf ; Check if ini file exist If FileExists($ini) Then $source = IniRead($ini, "SourceDir", "catalog", "NotFound") $dest = IniRead($ini, "DestDir", "catalog", "NotFound") $options = IniRead($ini, "RopocopyParamters", "options", "NotFound") $logg = '/log:' & @TempDir & '\_Robo-Sync-Robo.log ' & IniRead($ini, "RopocopyParamters", "logg", "NotFound") $what = IniRead($ini, "RopocopyParamters", "what", "NotFound") $active = IniRead($ini, "USB-Drive", "active", "NotFound") $usbdest = IniRead($ini, "USB-Drive", "catalog", "NotFound") $dractive = IniRead($ini,"DisplayResault","active","NotFound") Else _FileWriteLog($LogFile, $ini & " not found!! ") Exit EndIf $prog_source = $source & '\_script\robocopy.exe' $runner = ' "' & $source & '" "' & $dest & '" ' & $what & ' ' & $options & ' ' & $logg $usbrunner = ' "' & $dest & '" "' & $usbdest & '" ' & $what & ' ' & $options & ' ' & $logg ; Check for Robocopy, if not then copy from $source/_script path If FileExists(@ScriptDir & '\robocopy.exe') Then $robocopy = @ScriptDir & '\robocopy.exe' Else IF FileExists('c:\minint\system32\robocopy.exe') Then FileCopy('c:\minint\system32\robocopy.exe', @ScriptDir,1.0.0.2) Else FileCopy($prog_source, @ScriptDir,1.0.0.2) EndIf $robocopy = @ScriptDir & '\robocopy.exe' EndIf ; Robocopy job, runs according to settings in Robo-Sync.ini Sleep(50) If FileExists($source) Then $var = RunWait($robocopy & $runner, @ScriptDir, @SW_HIDE) _RoboErrorLevel() Else $var = 99 _RoboErrorLevel() EndIf ; Robocopy job for Copy from lokal dest to USB Drive, change settings in Robo-Sync.ini Sleep(50) If $active = 1 Then If FileExists($usbdest) Then $var = RunWait($robocopy & $usbrunner, @ScriptDir, @SW_HIDE) _RoboErrorLevel() EndIf Else $var = 98 _RoboErrorLevel() EndIf If $dractive = 0 Then $t_LogText = FileRead($LogFile) $s_LogText = FileRead(@TempDir&'\_Robo-Sync-Robo.log') MsgBox(0,"Robo-Sync Log file: ", $t_LogText & $s_LogText, 25) EndIf ; Checks the results / errorlevel from Robocopy and write to logfile Func _RoboErrorLevel() Sleep(100) If $var = 99 Then $err = $source & ' network not avalible at the moment...' ElseIf $var = 98 Then $err = $usbdest & ' USB Disk not avalible at the moment...' ElseIf $var = 16 Then $err = ' ***FATAL ERROR*** ' ElseIf $var = 15 Then $err = ' FAIL MISM XTRA COPY' ElseIf $var = 14 Then $err = ' FAIL MISM XTRA ' ElseIf $var = 13 Then $err = ' FAIL MISM COPY' ElseIf $var = 12 Then $err = ' FAIL MISM ' ElseIf $var = 11 Then $err = ' FAIL XTRA COPY' ElseIf $var = 10 Then $err = ' FAIL XTRA ' ElseIf $var = 9 Then $err = ' FAIL COPY' ElseIf $var = 8 Then $err = ' FAIL ' ElseIf $var = 7 Then $err = ' MISM XTRA COPY' ElseIf $var = 6 Then $err = ' MISM XTRA ' ElseIf $var = 5 Then $err = ' MISM COPY' ElseIf $var = 4 Then $err = ' MISM ' ElseIf $var = 3 Then $err = ' XTRA COPY' ElseIf $var = 2 Then $err = ' XTRA ' ElseIf $var = 1 Then $err = ' COPY' ElseIf $var = 0 Then $err = ' --no change-- ' EndIf _FileWriteLog($LogFile, "Resault from Robo-Sync: " & $err) EndFunc Robo-Sync.ini [RopocopyParamters]options = /R:15 /W:53 /TBD logg = /NP /NFL /NDL /NJH what = /COPYALL /B /SEC /MIR /XD _script [sourceDir] catalog = c:\temp [DestDir] catalog = c:\test [uSB-Drive] active = 1 catalog = "x:\Some Doc path" [DisplayResault] active = 1
water Posted January 7, 2018 Posted January 7, 2018 Welcome to AutoIt and the forum! This thread is more than 11 years old and the OP has been offline for more than 7 years. AutoIt, RoboCopy and Windows have cahnged a lot since then. So please do not necro old posts! My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Developers Jos Posted January 7, 2018 Developers Posted January 7, 2018 @Water.. clearly somebody that want to spam a tool. ... will be zapped soon. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now