?
Solved

Copy files with a login script

Posted on 2004-09-02
10
Medium Priority
?
278 Views
Last Modified: 2010-04-11
There are 3 files that reside at the C:\Documents and Settings\Default User\Application Data\"my application"  folder. I need to copy these 3 files from the mentioned location to C:\Documents and Settings\User A\Application Data\"my application folder.  The real problem is that I need to do this on about 50 computers and these computers are loged in by several users during the day.  Each user needs to have those files in their own profile user a, user b, user c etc.

Does any body know the sintax to accomplish this kind of task using a login script?  Ithe problem I have is that I don't know who is going to log in to what computer and to copy manually those files will be a big task.

My idea is,  at login to execute something like this copy C:\Documents and Settings\Default User\Application Data\My application\*.* C:\Documents and Settings\variable user\Application Data\my application\  What is the sintax for "variable user so it piks up the user name from the windows 2000 user name that is logged in.

ThanX for any help or ideas.
0
Comment
Question by:stylmark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 23

Expert Comment

by:rhandels
ID: 11969084
Hi,

First off all, create a batch file, that's called something like copy.bat, then add these rules

copy C:\Documents and Settings\Default User\Application Data\"my application" C:\Documents and Settings\User A\Application Data\"my application folder

Create a rule for each file you need to copy. You can add these rules in the loginscript they allready have..
0
 
LVL 1

Expert Comment

by:master_chris
ID: 11969269
@echo off

rem --- Begin Copy from Backup Directory to Local Drive
xcopy /v /c /i /h /r /y c:\*.* c:\mydata
echo "Copy has been Complete"

**note** Xcopy uses the old command prompt, so make sure u state the directory's properly. example
c:\docume~1\alluse~1\

0
 
LVL 76

Expert Comment

by:David Lee
ID: 11969697
Here's a script, VBScript, that'll copy the files.  Edit the scipt and change this line

    arrFiles = Array("FileOne.txt", "FileTwo.txt", "FileThree.txt")

substituting your filenames in place of mine.  I tested the script to make sure it works correctly, it did.  I didn't have a chance to test it in a login script though so I'm not sure if it'll be able to read the USEREPROFILE environment variable at that point.  I'm not sure at what point in the login process the environment variables get set.  If it doesn't work from the login script, then you could add it to each user's startup folder.  It should run fine from there.

Dim objFSO
Dim objShell
Dim objEnviron
Dim arrFiles
Dim intItem
Dim strSourcePath
Dim strDestPath
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set objEnviron = objShell.Environment("PROCESS")
strSourcePath = "C:\Documents and Settings\Default User\Application Data\My Application\"
strDestPath = objEnviron("USERPROFILE") & "\Application Data\My Application\"
wscript.echo strdestpath
arrFiles = Array("FileOne.txt", "FileTwo.txt", "FileThree.txt")
For intItem = 0 To 2
    objFSO.CopyFile strSourcePath & arrFiles(intItem), strDestPath & arrFiles(intItem)
Next
Set objEnviron = Nothing
Set objShell = Nothing
Set objFSO = Nothing
0
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 
LVL 1

Expert Comment

by:technicvn
ID: 11969959
Hi,
You could follow this instruction to gain your purpose  :
Create a new text file. Open it and type the following command:
@ echo off
Copy /Y \\your_PC_address\C$:\Documents and Settings\Default User\Application Data\My application\*.*  C:\Documents and Settings\variable user\Application Data\my application\
@ echo on
(The parameter /Y means: Suppresses prompting to confirm you want to overwrite an existing destination file)
Then save it as batch file, ex: Copy.bat
Then in user's profile, set this script.
That's all
Regards,
TeK
0
 
LVL 7

Accepted Solution

by:
wparrott earned 750 total points
ID: 11970027
Try this in your login script:

@echo off
REM Check for directory 1st
if not exist C:\Documents and Settings\%username%\Application Data\"my application" mkdir C:\Documents and Settings\%username%\Application Data\"my application"

REM Check for 1st file
if not exist C:\Documents and Settings\%username%\Application Data\"my application"\file1 copy C:\Documents and Settings\Default User\Application Data\"my application"\file1 C:\Documents and Settings\%Username%\Application Data\"my application"\file1

REM Check for 2nd file
if not exist C:\Documents and Settings\%username%\Application Data\"my application"\file2 copy C:\Documents and Settings\Default User\Application Data\"my application"\file2 C:\Documents and Settings\%Username%\Application Data\"my application"\file2

REM Check for 3rd file
if not exist C:\Documents and Settings\%username%\Application Data\"my application"\file3 copy C:\Documents and Settings\Default User\Application Data\"my application"\file3  C:\Documents and Settings\%Username%\Application Data\"my application"\file3

REM Continue with rest of login script


This will first check to see if the file exists or not, and if not, copy it from the \default user location to the currently logged in user's location. Of course, replace "my application" with the name of the folder you will be copying from.

Hope this helps...
0
 
LVL 3

Expert Comment

by:gnudiff
ID: 11971243
And finally yet another script,, add this to the login script, obviously you need to replace the COPYFILES with the names of the files you want to copy:

Works on my W2K:

SET COPYFILES=firstfile secondfile thirdfile
SET APPDIR=my application
SET GLOBALDIR=C:\Documents and Settings\Default User\Application Data\%APPDIR%
SET USERDIR=%USERPROFILE%\Application Data\%APPDIR%

FOR %%I IN (%COPYFILES%) DO COPY %GLOBALDIR%\%%I %USERDIR%
0
 
LVL 8

Expert Comment

by:holger12345
ID: 11978078
@gnudiff:
you may not have blanks in the names of COPYFILES ... (I wouldnt use names with blanks anywhere ;-) )
0
 
LVL 3

Expert Comment

by:gnudiff
ID: 11995591
i would have to check again, but i think it worked fine.
an alternative would be to put the contents of the variable in quotes, like:

FOR %%I IN (%COPYFILES%) DO COPY "%GLOBALDIR%"\%%I "%USERDIR%"
0
 
LVL 3

Expert Comment

by:gnudiff
ID: 11995605
oh, I think I got what you mean now, holger -- the COPYFILES variable uses blanks to separate file names, of course. It is meant to copy THREE files, each with a name without a blank.
If you need to copy files with blanks, you can put them in quotes perhaps too, like:

SET COPYFILES="first file" secondfile thirdfile

but not sure whether that'd work.
0
 

Author Comment

by:stylmark
ID: 12011696
Even though some of the other answers would probably had worked wparrott's answer was simple enough.  ThanX to everyone else
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
This program is used to assist in finding and resolving common problems with wireless connections.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question