Sign in with
Sign up | Sign in
Your question

Windows 7 batch file help

Last response: in Windows 7
Share
October 27, 2010 3:11:34 PM

Hi,

I have just created a batch file to backup a few things on my machine, the thing is the batch file has a menu in it and i was wondering if i was to set the batch file to run under task scheduler say once a week is there a way i can get it to excute through the menu of the batch file? if not when the task scheduler runs it, it will just stay a point waiting for me to press enter.

I have put a part of the batch file below to show you what i have done.

@ECHO OFF
ECHO WELCOME TO LIAM'S BACKUP WIZARD
GOTO MENU
:MENU
ECHO PLEASE SELECT A COMMAND BELOW BY PRESSING NUMBERS 1-4 FOR THE ITEMS THAT YOU WISH TO BACKUP
ECHO ===== BACKUP MENU LIST =====
ECHO 1. iTUNES MUSIC BACKUP
ECHO 2. MY PICTURES BACKUP
ECHO 3. FOOTBALL MANAGER 2011 BACKUP
ECHO 4. QUIT
SET /P N=TYPE 1, 2, 3 OR 4 THEN PRESS ENTER:
IF "%N%"=="1" GOTO iTUNES
IF "%N%"=="2" GOTO MY PICTURES
IF "%N%"=="3" GOTO FOOTBALL MANAGER 2011
IF "%N%"=="4" GOTO QUIT
:iTUNES
ECHO YOU HAVE CHOSEN TO BACKUP THE iTUNES MUSIC FOLDER PRESS ENTER TO CONTINUE
PAUSE
ECHO ------------------------------- >> "I:\Liam\XCOPY Backup Files\iTunes Music\BACKUP LOG.TXT"
ECHO %DATE% %TIME% >> "I:\Liam\XCOPY Backup Files\iTunes Music\BACKUP LOG.TXT"
ECHO ------------------------------- >> "I:\Liam\XCOPY Backup Files\iTunes Music\BACKUP LOG.TXT"
ECHO THE FOLLOWING FILES WILL BE COPIED
XCOPY "E:\Music\iTunes\iTunes Media\Music" "I:\Liam\XCOPY Backup Files\iTunes Music" /L /E /D /Y
PAUSE
XCOPY "E:\Music\iTunes\iTunes Media\Music" "I:\Liam\XCOPY Backup Files\iTunes Music" /E /D /Y >> "I:\Liam\XCOPY Backup Files\iTunes Music\BACKUP LOG.TXT"
ECHO FILE COPY COMPLETE
GOTO MENU

: MY PICTURES
ECHO YOU HAVE CHOSEN TO BACKUP THE MY PICTURES FOLDER PRESS ENTER TO CONTINUE
PAUSE
ECHO ------------------------------ >> "I:\Liam\XCOPY Backup Files\My Pictures\BACKUP LOG.TXT"
ECHO %DATE% %TIME% >> "I:\Liam\XCOPY Backup Files\My Pictures\BACKUP LOG.TXT"
ECHO ------------------------------ >> "I:\Liam\XCOPY Backup Files\My Pictures\BACKUP LOG.TXT"
ECHO THE FOLLOWING FILES WILL BE COPIED
XCOPY "E:\Pictures" "I:\Liam\XCOPY Backup Files\My Pictures" /L /E /D /Y
PAUSE
XCOPY "E:\Pictures" "I:\Liam\XCOPY Backup Files\My Pictures" /E /D /Y >> "I:\Liam\XCOPY Backup Files\My Pictures\BACKUP LOG.TXT"
ECHO FILE COPY COMPLETE
GOTO MENU

Hope you can help

Many thanks

More about : windows batch file

October 28, 2010 7:08:48 AM

craney said:
i was wondering if i was to set the batch file to run under task scheduler say once a week is there a way i can get it to excute through the menu of the batch file?


Hello, there could be several ways how to solve this.

Firstly, before we look at the actual script code, what do you want to actually do? Should one Scheduled Task always backup, say your music? And another task at a different time should backup some other stuff?
!