Solved

Using logon script  to copy file to logged on user's My documents folder\subdirectory

Posted on 2008-10-11
6
1,227 Views
Last Modified: 2012-08-13
With  group policy on win2003 AD, I need  a batch file to copy files  with
a user logon script.  I need to copy the *same*  file to two places when the user logs on to the PC



The \\server has full read for everyone, so permissions on server share is not an issue

First snippet copies the file to C:\windows and sets full access for all
(this part of the batch runs fine)

copy \\server\share\file.txt  C:\windows\file.txt
cacls \windows\file.txt  /t /c /g  everyone:f


Next I need to copy the file to a subdirectory in the currently logged on user;s My documents folder

WHen this part of the batch file runs, it stops with "Access denied"

copy \\server\share\file.txt  %homepath%\my documents\directory
pause

Since the logged on user has full rights to my documents, I'm not sure why access would be denied.
tried %userprofile% too, same results..

thanks


0
Comment
Question by:wlhelp
  • 3
  • 2
6 Comments
 
LVL 9

Assisted Solution

by:Gianpiero Rossi
Gianpiero Rossi earned 50 total points
ID: 22694278
try to write in the following way

copy \\server\share\file.txt  "%homepath%\my documents\directory"


there is a space in "my documents so you have to write the full path of the second argument between ""

Gianpiero
0
 

Accepted Solution

by:
wlhelp earned 0 total points
ID: 22695097
thanks for the feedback Gianpiero.. I'll test when back in the office on Monday
0
 

Author Comment

by:wlhelp
ID: 22706324
just tried using the %homepath% with above syntax, still getting access denied..
I have another way to try this .. will post update thanks
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 21

Assisted Solution

by:AmazingTech
AmazingTech earned 50 total points
ID: 22708411
%homepath% does not specify the drive. You should try it with %homedrive% as well.

copy \\server\share\file.txt  "%homedrive%%homepath%\my documents\directory"

copy \\server\share\file.txt  "%UserProfile%\my documents\directory"
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22708413
Maybe also need quotes for the target.

0
 

Author Comment

by:wlhelp
ID: 22711280

all set on this one,
also needed to test for previously installed ini file, and ignore the update if
dt.txt existed



IF EXIST  "%homepath%\my documents\datatel\dt.txt" GOTO END
IF NOT EXIST  "%homepath%\my documents\datatel\dtini.txt" GOTO START

:START
copy \\server\msi\datatel\DT.txt  "%homepath%\my documents\datatel"  /y
copy \\server\msi\datatel\DTini.txt  "%homepath%\my documents\datatel"  /y
pause
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now