• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2736
  • Last Modified:

xcopy .bat files

I want to write  an xcopy .bat file that will transfer new application files from my server to my clent machines.  Right now I am going to each client machine and cpoying the files manually.

Can anyone hlep me with this?

The environment is server 2003 and XP pro.

Wes
0
hmcnasty
Asked:
hmcnasty
  • 11
  • 7
  • 3
  • +2
4 Solutions
 
SteveGTRCommented:
I'd recommend doing this in a Group Policy Script.

@echo off

copy "\\server\share\dir\program.exe" "c:\program files"
0
 
Christopher McKayCommented:
Can you provide a bit more information regarding your environment?

Are you wanting to add this batch file to the logon script for the domain? Are the files you want copied going to the same place on each workstation? Do these files need to be installed, or will just copying them be sufficient?
0
 
amit_gCommented:
xcopy /D /I /E /Y /C /R /V /K /H \\ServerMachine\c$\Whatever \\ClientMachine\c$\Whatever
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
hmcnastyAuthor Commented:
Steve,
How would I right this in a Group policy script?  I've never done that.

Bartender1,

All my clients are running XP Pro and the servers are 2003.  We are developing a .net application for the client.  We have updates to the application 1 to 2 times a week.  Right now I go to each client mmachine and cpoy the new files from the server to the clients.  I 'm looking for an eaiser way becasue thier are 80+ clinets in 5 locations.  So I was thinking a .bat file that the clinets could run at thier leisure to copy the updates for them or maybe a glbal type of thing that I can run at night and would update all the machines per location.  

w
0
 
hmcnastyAuthor Commented:
Amit, I think this is what I'm looking for how would I save it as a .bat or small exe to run whenever I want to with out going into CMD everyitme and typing it in?

W
0
 
Christopher McKayCommented:
The command offered by amit_g will work for you.

How do you wish to have this copying accomplished? Do you want the clients to do it manually, or do you want to automate it. (Doing it manually means they may not do it, causing problems, automating it means the computer could get copy errors, and not actually accomplish the copying causing errors.... etc, so how you plan on deploying will let us know what to suggest for ease of deployment.)
0
 
hmcnastyAuthor Commented:
I would like to automate it so that I can do it when I want.

w
0
 
amit_gCommented:
I use something like this for my own .Net application deployment

@echo off

xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\*.sitemap \\MyServer\c$\WebSites\MyApp\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\*.asax \\MyServer\c$\WebSites\MyApp\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\*.aspx \\MyServer\c$\WebSites\MyApp\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\*.ascx \\MyServer\c$\WebSites\MyApp\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\*.master \\MyServer\c$\WebSites\MyApp\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\*.asax.cs \\MyServer\c$\WebSites\MyApp\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\*.aspx.cs \\MyServer\c$\WebSites\MyApp\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\*.ascx.cs \\MyServer\c$\WebSites\MyApp\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\*.master.cs \\MyServer\c$\WebSites\MyApp\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\bin \\MyServer\c$\WebSites\MyApp\bin\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\Images \\MyServer\c$\WebSites\MyApp\Images\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\App_Code \\MyServer\c$\WebSites\MyApp\App_Code\
xcopy /Y /D /R /E C:\InetPub\WWWRoot\MyApp\App_Themes \\MyServer\c$\WebSites\MyApp\App_Themes\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\scripts \\MyServer\c$\WebSites\MyApp\scripts\
xcopy /Y /D /R C:\InetPub\WWWRoot\MyApp\Controls \\MyServer\c$\WebSites\MyApp\Controls\

ping -n 6 127.0.0.1 > nul

I could use the single xcopy with /Exclude (for example I don't want to deploy web.config) but I found it much more easier to list exactly I want to deploy. I keep changing this file specific to each project. But if you want to deply everything you could use the global xcopy as I posted earlier. You could use several servernames/clientnames and/or folders in the same batch file.
0
 
Christopher McKayCommented:
You could save it as a batch file, by following these steps:

open a new notepad file,
copy the command into the file
save and close the file
rename the file to "something.bat" (without the quotes)
then you can copy the batch file to a server location.
0
 
hmcnastyAuthor Commented:
@echo off

xcopy /Y /D /R C:\RIISOfficeManagementSystem\*.*  \\tw4\c$\Prism Solutions Group\RIIS Office Mangament System

I tried this with no luck.  management is spelled incorrectly on purpose.

It just blinks on the screen real quick and nothing happends.
0
 
r-kCommented:
If you have spaces in names then include within quotes, e.g.

xcopy /Y /D /R C:\RIISOfficeManagementSystem\*.*  "\\tw4\c$\Prism Solutions Group\RIIS Office Mangament System"

Also, to debug such problems, first run the command manually from a command prompt window. If it works then put it in a command file.

HTH.
0
 
hmcnastyAuthor Commented:
I think I got it.  It  runs and asks me does "\\tw4\c$\Prism Solutions Group\RIIS Office Mangament System"
specifiy a file or directory?  I selected directory and it ran.  Is there a way to not make it ask that every time?

W
0
 
Christopher McKayCommented:
Have you tried adding a "\" after the name?

"\\tw4\c$\Prism Solutions Group\RIIS Office Mangament System\"

Hope this helps!

:o)

Bartender_1
0
 
Christopher McKayCommented:
Wups... this will work better:

xcopy /Y /D /R /I C:\RIISOfficeManagementSystem\*.*  "\\tw4\c$\Prism Solutions Group\RIIS Office Mangament System"
0
 
hmcnastyAuthor Commented:
Thanks.

This is what I got.

Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\Documents and Settings\Administrator.INDOORSPORTS>xcopy /Y /D /R /I C:\RIISOffic
eManagementSystem\*.* "\\tw4\C$\Prism Solutions Group\RIIS Office Mangament Syst
em\"
0 File(s) copied

I put a test.txt file in the directory and that seems to come over but that the only one.  Strange.

w
0
 
hmcnastyAuthor Commented:
So it looks like it will add new items to the directory but not replace old ones.

W
0
 
Christopher McKayCommented:
What is the purpose of specifying the /D switch? You don't include a date with it, so it will only copy files if the destination file is older than the current file. Have you confirmed that the files being copied are newer?
0
 
hmcnastyAuthor Commented:
Oh wait a minute.  it won't replace the same file wil it.  I think these updates are already done that's why it doesn't seem like it 's working.

0
 
hmcnastyAuthor Commented:
right

it work fine

Thank you. Thank you. Thank you.

Wes
0
 
hmcnastyAuthor Commented:
What does echo off do?

w
0
 
Christopher McKayCommented:
@ echo off

tells the batch file to not show the commands it is entering at the prompt.

If you remove that line, it would show the commands being fed to the system at the command prompt, instead of just the results of the commands.
0
 
r-kCommented:
Thanks and good luck.
0
 
hmcnastyAuthor Commented:
Ok..Thanks again.  I ahve one more question.

Everything is coming over except there is an images folder that resides in C:\RIISOffic
eManagementSystem\ . It's not getting copied however is does get deleted in the process. How do I get this one over?
W
0
 
r-kCommented:
Include the /S switch to include subfolders. You may find some of the following options useful:

Rem       /s  means all subdirectories also
Rem       /e  means empty folders also
Rem       /c  means ignore errors
Rem       /f  means full display in console window
Rem       /h  means hidden files also copied
Rem       /d  means copy only those files that have changed
Rem       /y  means do not prompt for overwriting existing files
Rem       /o  means retain file ownership and acl info
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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