tgallup
(Fresh Scripter)
2009-06-23 02:39 PM
Is it Possible to sync files?

We have a network share that everyone maps to through kix, is there a way to run a script near the end of the logon script that will sync any files within a directory to a directory on your C drive. We have report files that are called by our ERP system and we have to manually copy them right now to each computer when one changes and wanted a way to synch them instead.

Thanks


Glenn BarnasAdministrator
(KiX Supporter)
2009-06-23 03:18 PM
Re: Is it Possible to sync files?

A simple RoboCopy command would work well, called via SHELL. Make sure to use the latest version of RoboCopy.

Glenn


tgallup
(Fresh Scripter)
2009-06-23 04:01 PM
Re: Is it Possible to sync files?

Can you give me instructions on how this works? I have never used this command now have I done lots of scripting in Kix.

Glenn BarnasAdministrator
(KiX Supporter)
2009-06-23 04:55 PM
Re: Is it Possible to sync files?

Go to Microsoft's web site to download RoboCopy - it's part of the Resource Kit.

RoboCopy is similar to XCopy, but faster and a bit more feature rich. Run RoboCopy /??? for usage instructions. The command will look something like:
 Code:
Shell 'robocopy sourcepath destpath /E /PURGE'
- "PURGE" will remove files on the PC that are no longer in the central folder - use this with caution!

Glenn


tgallup
(Fresh Scripter)
2009-06-23 05:34 PM
Re: Is it Possible to sync files?

will robocopy need to be installed on each users computer?

Glenn BarnasAdministrator
(KiX Supporter)
2009-06-23 07:33 PM
Re: Is it Possible to sync files?

Put it in netlogon folder and call it from there..

Glenn


tgallup
(Fresh Scripter)
2009-06-23 07:53 PM
Re: Is it Possible to sync files?

I appologize for not understanding, but how will you be able to do that?

Glenn BarnasAdministrator
(KiX Supporter)
2009-06-23 08:37 PM
Re: Is it Possible to sync files?

Put the RoboCopy.exe into the same folder (netlogon) as the Kix32 and kix login script. During the login process, the netlogon folder is in the user's path. Use the earlier example (modified to reflect your source and local destination directories) in your login script to sync the user folder with the server's content.

Glenn


tgallup
(Fresh Scripter)
2009-06-23 08:50 PM
Re: Is it Possible to sync files?

This is what I have, but it doesn't seem to be working

;----synch Reports ------

Shell 'robocopy \\servername\mas\Reports\AR C:\Program Files\Sage Software\Sage MAS 500 Client\AR\Reports\Test /E'

sleep 2


eriqjaffe
(Hey THIS is FUN)
2009-06-23 09:41 PM
Re: Is it Possible to sync files?

There are spaces in the robocopy line, which will throw it off.

 Code:
;----synch Reports ------

Shell 'robocopy \\servername\mas\Reports\AR "C:\Program Files\Sage Software\Sage MAS 500 Client\AR\Reports\Test" /E'

sleep 2


tgallup
(Fresh Scripter)
2009-06-23 10:01 PM
Re: Is it Possible to sync files?

Ok this is what I have now, still not working at all

Shell "robocopy \\servername\mas\Reports\AR ("%Program Files%\Sage Software\Sage MAS 500 Client\AR\Reports\Test") /E"


Glenn BarnasAdministrator
(KiX Supporter)
2009-06-23 11:31 PM
Re: Is it Possible to sync files?

Why are you adding parenthesis? Why did you change the single quotes to double quotes? eriqjaffe's sample code was correct as posted!

Review the readme/active help for robocopy and the Kix manual for the Shell command to make sure your syntax is correct.

Anytime you have spaces in filenames, they must be surrounded in quotes. Kix treats single and double quotes alike, but DOS commands generally REQUIRE double quotes to be happy. Thus, you use Single quotes to define the Kix command, and double quotes inside the single quotes to encapsulate the paths.
 Code:
shell 'robocopy sourcepath "dest path with spaces" /E'
Note the single quotes to delimit the ENTIRE shell command, and the double quotes to delimit only the "path with spaces".

Glenn


tgallup
(Fresh Scripter)
2009-06-24 04:59 PM
Re: Is it Possible to sync files?

This is what I have now, but the files still are not copying to my local drive.

Shell 'robocopy \\servername\MAS\Reports\AR "%Program Files%\Sage Software\Sage MAS 500 Client\AR\Reports\Test" /E'


Glenn BarnasAdministrator
(KiX Supporter)
2009-06-24 07:57 PM
Re: Is it Possible to sync files?

That looks good. What happens when you run the command from a command prompt, without the "SHELL" or the single quotes - as in
 Code:
C:> robocopy \\servername\MAS\Reports\AR "%Program Files%\Sage Software\Sage MAS 500 Client\AR\Reports\Test" /E
Any error messages?

Glenn


tgallup
(Fresh Scripter)
2009-06-24 08:04 PM
Re: Is it Possible to sync files?

I am not getting any errors that i know of, nothing when the script runs...

Gargoyle
(MM club member)
2009-06-24 08:36 PM
Re: Is it Possible to sync files?

Add a @SError right after the command in your script. Robocopy will set an error code depedent on what it did or did not do.

Glenn BarnasAdministrator
(KiX Supporter)
2009-06-24 08:54 PM
Re: Is it Possible to sync files?

To avoid issues with the SCRIPT and determine if you're getting a ROBOCOPY error, you need to open a command prompt and run the robocopy command, just as if the script had executed it. It might shed some light on why the script is failing.. The idea is to divide and conquer.

Gargoyle's suggestion to use @SERROR is also valid, but may not tell you the whole story. RoboCopy (and most commands) exit with a numeric code that Kix will translate into a standard status message. Sometimes, this can result in misleading messages. Running just the robocopy command from a command prompt will tell you that it's working (or not) and if not, provide direct and meaningful messages from the app, and not those that are interpreted by Kix.

Glenn


tgallup
(Fresh Scripter)
2009-06-24 09:01 PM
Re: Is it Possible to sync files?

I am getting %1 is not a valid win32 application

Glenn BarnasAdministrator
(KiX Supporter)
2009-06-24 10:15 PM
Re: Is it Possible to sync files?

Then it can't find robocopy.exe. Did you copy it to your workstation? Is it in the system path or the folder you opened your command prompt to?

If you copied it to the netlogon folder (as I suggested) then it isn't on your workstation - you will need to reference the path (\\mydomain\netlogon\robocopy.exe) for it to work on your PC. During the logon process, that folder is in the system path, so it should be found. Outside of the logon process, it won't be, so you'll need to explicitly define it while testing.

Glenn


tgallup
(Fresh Scripter)
2009-06-24 10:53 PM
Re: Is it Possible to sync files?

I added the @SERROR to the end of the command and that is what came back

Gargoyle
(MM club member)
2009-06-25 01:23 AM
Re: Is it Possible to sync files?

Here is the exact code (sanatized of course) that I used to move 1200 users home folders with Robocopy.

Maybe it will give you an idea of what you are doing incorrectly. And as Glenn said, you need to run it from a command line. Not from a script to see what is going on with it.

 Code:
$Options = "/R:2 /Z /W:2 /CopyAll /MOV /E /V /NP /LOG+:\\server\c$\scripthome\logs\"+$AD_User+".txt"
Shell "%comspec% /c \\server\c$\scripthome\bin\Robocopy " + $Directory + " " + "\\store\homedir$\" + Left($AD_User,1) + "\" +$AD_User+"\ "+ $Options
$Result_Flag[0] = @ERROR
$so = WriteLine ($fh,"HomeShare move attempted exit code of :" + $Result_Flag[0] + " " + @CRLF)


tgallup
(Fresh Scripter)
2009-06-25 02:22 PM
Re: Is it Possible to sync files?

The issue was the robocopy.exe program. I had the one running from server 2008, i copied up the one from the server 2003 resource kit and all is well now, thank you all for your help.