Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy file via login script issue 2

Status
Not open for further replies.

andyds

IS-IT--Management
Feb 22, 2007
91
GB
Can anyone tell me what line of code I need in my login script to perform the following:

I want to copy a file Normal.dotm from a global directory that all users have access to. The path = G:\Global\Normal.dotm

I want the file to be copied to C:\Documents and Settings\USER\Application Data\Microsoft\Templates\

The file being copied needs to overwite the current one in the directory of the same name.

Two problems here I can’t figure out. Firstly, the user does not have access to the C:\ drive by default. Secondly how does the script know to copy the file to the current USER logging in?

Any help would be appreciated.
 
Firstly I would use a little MS application called "Robocopy".
Its very powerful and easy to use. It comes as part of the resource kit. Google will help you here. Then you would want a script similar to this:

robocopy "\\servername\global" "C:\Documents and Settings\%username%\Application Data\Microsoft\Templates" normal.dotm

Please test this first, I am doing it straight of the top of my head but it should work ok. Use UNC paths to the server otherwise you would first have to map a drive to G which would be more complicated and not needed.
Share the "global" folder with access to all users.
TIP: Copy the robocopy .exe into your system32 folder first.


*****************************************
Your mouse has moved - reboot for changes to take effect
 
Just thinking about this now - you would probably have to copy robocopy to ever single machine first which if you have a lot would be counter productive. Use Xcopy command instead then.

xcopy "\\servername\global\normal.dotm" "C:\Documents and Settings\%username%\Application Data\Microsoft\Templates" /Y /C

This should work but again please test. The /Y switch will override the current file and the /C will not stop on error

*****************************************
Your mouse has moved - reboot for changes to take effect
 
It didn't work I'm afraid. Came up with a compilation error.

Expected End of statement at Line 3 CHAR 70 Code 800A0401
 
Char 70 is the " at the begining of the C:\documents and Settings FYI
 
Andy - it doesnt sound like that error is related to this simple copy script. Do you have many other things running in your login script? Is it a batch file or kix or ??
Create a simple batch file with this copy script and run it manually on the machine. It should work. Then make that same batch file run as a login script. It should work again.
Then incorporate it into your normal login script in the knowledge that it works fine or if not you know where to start troubleshooting.
Let me know if I can help more.

*****************************************
Your mouse has moved - reboot for changes to take effect
 
I created a simple batch file with this copy script and run it manually on my pc. It still came up with the error on line 1 Char 70. It must be a syntax error. No idea what though?

The line is exactly how you had but the path is longer to the file thats the only difference.

xcopy "\\servername\global\normal.dotm" "C:\Documents and Settings\%username%\Application Data\Microsoft\Templates" /Y /C
 
Yeah thats strange. I have just tried the same little batch file with only the copy script line and it worked fine for me.
Some troubleshooting tips to try.

Copy the line: "C:\Documents and Settings\%username%\Application Data\Microsoft\Templates" into the run box and hit ok. It should open the correct folder. Remember to always keep the Inverted Commas (double quotation marks)

Also test your Xcopy functonality by doing a simple test copy.

It should really work.
Failing that and even instead of go with my initial suggestion and Pat's clever addition to use Robocopy and call it from the server. The script would then look similar to this:

\\sharedserver\share\robocopy robocopy "\\servername\global" "C:\Documents and Settings\%username%\Application Data\Microsoft\Templates" normal.dotm

hope it helps.

*****************************************
Your mouse has moved - reboot for changes to take effect
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top