Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-11
6
Medium Priority
?
1,243 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
[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
  • 3
  • 2
6 Comments
 
LVL 9

Assisted Solution

by:Gianpiero Rossi
Gianpiero Rossi earned 200 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
[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

 
LVL 21

Assisted Solution

by:AmazingTech
AmazingTech earned 200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

705 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