Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1274
  • Last Modified:

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

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
wlhelp
Asked:
wlhelp
  • 3
  • 2
3 Solutions
 
Gianpiero RossiSystem AdministratorCommented:
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
 
wlhelpAuthor Commented:
thanks for the feedback Gianpiero.. I'll test when back in the office on Monday
0
 
wlhelpAuthor Commented:
just tried using the %homepath% with above syntax, still getting access denied..
I have another way to try this .. will post update thanks
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
AmazingTechCommented:
%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
 
AmazingTechCommented:
Maybe also need quotes for the target.

0
 
wlhelpAuthor Commented:

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

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now