Solved

Issue Copying Files to %windir% from bat file through Group Policy

Posted on 2009-05-12
10
1,133 Views
Last Modified: 2013-12-12
All,
I need some help  I am trying to run a batch files that copies files from a network location. This batch file is being called as a start script through Group Policy for the Computer Policy.

Everytime it runs it takes a long time to go through running start up scripts and then the files do not get copied over to the %windir%, however if i run the batch file after i log in it works just file, I need this to work when the computer boots up as a start script.
0
Comment
Question by:navajo26354
10 Comments
 
LVL 8

Expert Comment

by:Perry_IDITC
ID: 24369409
Hi,

What are you trying to acomplish with this script? can you provide an example of the script you are using?

Cheers,
Perry
0
 
LVL 47

Assisted Solution

by:Donald Stewart
Donald Stewart earned 100 total points
ID: 24369446
try this way
If Exist x:\ net use x: /delete
net use x: \\server\share
copy /y x:\yourfiles.txt C:\windows\system32\
0
 
LVL 84

Expert Comment

by:oBdA
ID: 24369523
If you can copy it when logged on, but the machine itself doesn't during boot, then the machine account probably doesn't have permissions to access the share where the source files are.
Either give "Authenticated Users" at least Read permissions on the source (share and NTFS), or give it to the computer account.
Another option (with no need to change permissions) is to create a folder in the netlogon share, copy the files into this folder, and then use something like this to copy:
copy "\\your.domain.local\netlogon\TheSourceFolder\SomeFile.exe" "%Systemroot%"

In addition, you should implement some logging, especially in a startup script where you can't see things happening (unless you explicitly enable this with a policy). ">>SomeFileName.log" will redirect the normal output, "2>&1" will redirect stderr into stdout, so that you'll catch error messages as well:


set LogFile=C:\Temp\startup.log
if not exist "C:\Temp" md "C:\Temp"
if exist "%LogFile%" del "%LogFile%"
copy "\\your.domain.local\netlogon\TheSourceFolder\SomeFile.exe" "%Systemroot%" >>"%LogFile%" 2>&1

Open in new window

0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:navajo26354
ID: 24369534
I am copying a Scr file that i built currently my bat file runs this copy "\\pfsweb.com\files\public\matt\p&g\*.*" %windir%\ /y

it works after being loggs in
0
 

Author Comment

by:navajo26354
ID: 24369721
The share folder that i am pulling from everyone have read rights to it, to be more specific, authenticated users.
0
 
LVL 84

Accepted Solution

by:
oBdA earned 400 total points
ID: 24369819
Try to run this; if you don't see a listing of the source folder in C:\temp\startup.log, the permissions are incorrect, or something else is preventing network access for the computer.
If it doesn't work, you might want to try to copy the "p&g" folder into the netlogon share, and use "\\pfsweb.com\netlogon\p&g\*.*" as source; the netlogon folder has the correct permissions for computer accounts to access it.
set LogFile=C:\Temp\startup.log
if not exist "C:\Temp" md "C:\Temp"
if exist "%LogFile%" del "%LogFile%"
echo Source Directory:
dir "\\pfsweb.com\files\public\matt\p&g" >>"%LogFile%" 2>&1
copy "\\pfsweb.com\files\public\matt\p&g\*.*" "%Systemroot%" >>"%LogFile%" 2>&1

Open in new window

0
 

Author Comment

by:navajo26354
ID: 24369914
one more thing i have granted teh \\pfsweb.com\files\matt share read access to domain computer group
0
 

Author Comment

by:navajo26354
ID: 24369928
would it work if i droped it in the group policy share?
0
 

Author Comment

by:navajo26354
ID: 24369930
nvm that is in net logon :-)
0
 
LVL 84

Expert Comment

by:oBdA
ID: 24377667
The script above expects the source directly in a subfolder "p&g" in the netlogon share (usually C:\Windows\sysvol\sysvol\your.domain.local\scripts, or simply \\YourDC\netlogon)--way easier to find and to edit than in the group policy folder.
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

All of the resources available today make learning a new digital media easier than ever-- if you know where to begin. This is a clear, simple guide to a few of the basic digital art mediums and how to begin learning them on your own.
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

830 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