C#/.BAT file

Advertisement


Question
QUESTION: I am running win7 and I wanted to make a .BAT File that when I click on it it will run a Backup.

I want to Backup a Folder called Notes on my Desktop on my C: Drive to my E: Drive.

So I did this code in notepad and saved it as .bat and yes I changed file format to ALL in the dropdown list.

xcopy c:\Users\Robert\Notes
e:\Roberts Backup
/e/v/c/y/f

<c:\Users\Robert\Desktop\Backuplog.txt

And this last line of code sould output a text Log file to my Desktop. But when I click this file it looks like it is trying to open I can see an outline of a big window and then it goes away.

And it never Runs or Backsup the Folder.

I just would like to know how to do this code thanks.

ANSWER: Hi there,

This line alone should do the trick:

xcopy C:\Users\Robert\Notes E:\Roberts Backup /E /V /C /F /Y >C:\log.txt

Hope that helps,

Murat

---------- FOLLOW-UP ----------

QUESTION: Thank you for getting back to me.
I did try the code you gave me
xcopy C:\Users\Robert\Notes E:\Roberts Backup /E /V /C /F /Y >C:\log.txt

And yes I save it as   .bat file and yes I change format type to   All Files.

But when I Dabble Click it an Outline of a Window opens and then goes away. And when I check my E" Drive it did not copy the Folder Notes from my Desktop.

When I save this File in Notepad there is a Dropdown list for Encodeing Type.

Sould I pick   ASSCi   it is set to   ANSi?

Answer
In order to see the result message of window, append this line:

@PAUSE

Except this, check these:
- File must be saved in ANSI format.
- The path: C:\Users\Robert\Notes does not target your desktop. If your Notes folder is on desktop, then it should be as following: C:\Users\Robert\Desktop\Notes . So please check paths well.
- Check also if E:\Roberts Backup path exists, and if exists, rename folder to E:\Roberts_Backup and also in bat file, else create it.

Hope that helps,

Murat

C#

All Answers


Answers by Expert:


Ask Experts

Volunteer


Murat Mehmet

Expertise

I can help with questions about desktop and web programming in C#, including SOAP, XML, database managing, custom controls, security etc.

Experience

I have been developing web and especially desktop applications in C# and VB.Net for almost 5 years. My programming life has begun with VB6 long time ago, so its about 8 years that I am in this business.

Organizations
Was in R & D for 2 years in a popular Turkish technology website: cyber-warrior.com

Education/Credentials
2011 Computer Engineering graduation in University of Trakia in Turkey.

©2016 About.com. All rights reserved.