[Webinar] Streamline your web hosting managementRegister Today

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

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

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
navajo26354
Asked:
navajo26354
2 Solutions
 
Perry_IDITCCommented:
Hi,

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

Cheers,
Perry
0
 
Donald StewartNetwork AdministratorCommented:
try this way
If Exist x:\ net use x: /delete
net use x: \\server\share
copy /y x:\yourfiles.txt C:\windows\system32\
0
 
oBdACommented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
navajo26354Author Commented:
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
 
navajo26354Author Commented:
The share folder that i am pulling from everyone have read rights to it, to be more specific, authenticated users.
0
 
oBdACommented:
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
 
navajo26354Author Commented:
one more thing i have granted teh \\pfsweb.com\files\matt share read access to domain computer group
0
 
navajo26354Author Commented:
would it work if i droped it in the group policy share?
0
 
navajo26354Author Commented:
nvm that is in net logon :-)
0
 
oBdACommented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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