rpettit Posted May 15, 2011 Posted May 15, 2011 I need a script to copy a file from the server to a client machine and next time it is run it will check to see if the file is present. If it has already copied then the script will check and not copy the file down again copy /Y "\\DomainController\Share$\File Location" "C:\\Documents and Settings\All Users\Start Menu\Programs\" This is what I have so far
glennda Posted May 15, 2011 Posted May 15, 2011 you want something like if exist C:\path\to\file.exe goto end xcopy \\server\share\file.exe C:\path\to\file.exe /relevant /parameters /here end or you could do if exist C:\filename.txt goto end xcopy \\server\share\file.exe C:\path\to\file.exe /relevant /parameters /here echo done>C:\filename.txt end 1
rpettit Posted May 15, 2011 Author Posted May 15, 2011 Many thanks for the reply. I might need to post another thread but can you help to start with please? Is there a way to create a script that will also create a schedule task to run a batch file on shutdown? To give a full explanation...I need to copy a file (script) from the server to the client. The script will also need to create a schedule task to run the script on shutdown that has just been copied to the client.
glennda Posted May 15, 2011 Posted May 15, 2011 I think you can deploy scheduled tasks through Group Policy Preferences nowadays which might be easier solution. What is it the scripts actually need to do i.e could you not setup it as a shutdown script just like the startup script you are going to do?
rpettit Posted May 15, 2011 Author Posted May 15, 2011 I am looking to: 1) Copy a file from server to client (a security template) 2) Create a batch file to deploy the security template on shutdown (every time the machine is shutdown) 1) This will copy the file from the server the client. if exist C:\path\to\file.exe goto end xcopy \\server\share\file.exe C:\path\to\file.exe /relevant /parameters /here end Now I need a batch file to deploy the template via a script to run during shutdown.
glennda Posted May 15, 2011 Posted May 15, 2011 Now I need a batch file to deploy the template via a script to run during shutdown. I don't understand what you mean by this - what sort of security template for what? is it something which needs to be executed? if so by what program etc
rpettit Posted May 15, 2011 Author Posted May 15, 2011 I want to want to disallow local access when connected to the domain, but allow local access when at home. I can do this by deploying a computer security policy via a GPO. I need to change the security policy when the machine shutdowns. So when they are at home they can access their local account and when they are in the school domain the policy will again be applied and restrict access. I will create a security template and then apply this via a script or schedule task on computer shutdown.
glennda Posted May 15, 2011 Posted May 15, 2011 ok not sure how you would implement the security template from a script. but gpos tend to hand around so you might find that when the laptop boots again the gpo's applied which redisables local connections.
SYNACK Posted May 15, 2011 Posted May 15, 2011 (edited) You would want to use the "secedit.exe /import" command. Not sure if it will work right with GP though, a better bet may be to run a script to disable all local user accounts instead: '************************************************* ' File: Disable Local User Accounts.vbs ' Author: Andrew Barnes ' version: 1.0 Date: 07 September 2009 By : Andrew D Barnes ' Lists local accounts and disables all except local admin and ASPNET '************************************************* Set objShell = CreateObject("Wscript.Shell") Set objNetwork = CreateObject("Wscript.Network") strComputer = objNetwork.ComputerName Set colAccounts = GetObject("WinNT://" & strComputer & "") colAccounts.Filter = Array("user") Message = Message & "Local User accounts:" & vbCrLf & vbCrLf For Each objUser In colAccounts If objUser.Name <> "Administrator" AND objUser.Name <> "ASPNET" Then Message = Message & objUser.Name If objUser.AccountDisabled = TRUE then Message = Message & " is currently disabled" & vbCrLf Else Message = Message & " was enabled" & vbCrLf objUser.AccountDisabled = True objUser.SetInfo End if End If Next ' Initialize title text. Title = "Local User Accounts By Andrew Barnes" objShell.Popup Message, , Title, vbInformation + vbOKOnly http://gallery.technet.microsoft.com/scriptcenter/47ad1824-5af7-451e-a9f5-f6dd90421394 then reverse the process to allow them in at home. Edited May 15, 2011 by SYNACK
Arthur Posted May 16, 2011 Posted May 16, 2011 Instead of... if exist C:\path\to\file.exe goto end xcopy \\server\share\file.exe C:\path\to\file.exe /relevant /parameters /here :end You could simplify it even further still... if exist C:\path\to\file.exe goto :eof xcopy \\server\share\file.exe C:\path\to\file.exe /relevant /parameters /here if not exist C:\path\to\file.exe xcopy \\server\share\file.exe C:\path\to\file.exe /relevant /parameters /here robocopy \\server\share\file.exe C:\path\to\file.exe [color="red"]/XO[/color] /R:0 /W:0 /NP * RoboCopy is included as standard with Windows 7 and Server 2008 R2.
SYNACK Posted May 16, 2011 Posted May 16, 2011 +1 use robocopy instead, way more robust and simple scriptwise.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now