Solved

Need script to copy & replace a backup file on Windows PC to Windows server.

Posted on 2011-03-11
7
397 Views
Last Modified: 2012-05-11
I need a script to copy a backup file from a Windows XP computer to a Windows server 2008 by using the task manager on the XP computer....rough mapping would be...

\\UserPC\deptfile\backup\backup.bak

to

\\server\data\dept\backup\

The XP computer is on a domain with access to the server.

Also need the script to overwrite the previously backed up file on the server. Thx.
0
Comment
Question by:Wilmette
7 Comments
 
LVL 8

Expert Comment

by:jawa29
Comment Utility
Hi Wilmette

How's this?

Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "\\UserPC\deptfile\backup\backup.bak" , "\\server\data\dept\backup\", OverwriteExisting

Jawa29

0
 
LVL 3

Accepted Solution

by:
brd24gor earned 500 total points
Comment Utility
Alternatively, you could have your task run this line of code without needing a script:
echo F | xcopy /y /f /i \\UserPC\deptfile\backup\backup.bak \\server\data\dept\backup\backup.bak

Open in new window

0
 
LVL 51

Expert Comment

by:Bill Prew
Comment Utility
Save this as a BAT file, and then create a scheduled task in Windows task scheduler to run it at the desired time and frequency.

@echo off
set CopyFile=\\UserPC\deptfile\backup\backup.bak
set DestDir=\\server\data\dept\backup
if not exist "%DestDir%\" md "%DestDir%\"
xcopy /y "%CopyFile%" "%ToDir%\"

Open in new window

~bp
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Expert Comment

by:Flipp
Comment Utility
If you need a good solid tool for this type of oPeration, then you can try Robocopy from the 2003 Resource Kit.
0
 

Author Comment

by:Wilmette
Comment Utility
Thanks for the replies. I forgot to explain that the script will be run daily in MS Task Manager.
0
 

Author Comment

by:Wilmette
Comment Utility
I should say...Task Scheduler not Task Manager...ooops
0
 
LVL 6

Expert Comment

by:Flipp
Comment Utility
You can use either solution by creating an executable scripted file and then calling that file from the MS Scheduled Task.

Do you need the code for the function you requested above?
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I comeā€¦
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now