|
|
|||||||
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 |
||||||||
|
|
|||||||
A simple RoboCopy command would work well, called via SHELL. Make sure to use the latest version of RoboCopy. Glenn |
||||||||
|
|
|||||||
Can you give me instructions on how this works? I have never used this command now have I done lots of scripting in Kix. |
||||||||
|
|
|||||||
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' Glenn |
||||||||
|
|
|||||||
will robocopy need to be installed on each users computer? |
||||||||
|
|
|||||||
Put it in netlogon folder and call it from there.. Glenn |
||||||||
|
|
|||||||
I appologize for not understanding, but how will you be able to do that? |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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" |
||||||||
|
|
|||||||
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' Glenn |
||||||||
|
|
|||||||
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' |
||||||||
|
|
|||||||
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 Glenn |
||||||||
|
|
|||||||
I am not getting any errors that i know of, nothing when the script runs... |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
I am getting %1 is not a valid win32 application |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
I added the @SERROR to the end of the command and that is what came back |
||||||||
|
|
|||||||
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) |
||||||||
|
|
|||||||
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. |