1.

Solve : Will This Batch File Work In Windows 7?

Answer»

I am planning to install Windows 7 in next few days and WONDERING if the following batch file will WORK. Thank you. (I put this question in Windows Vista and Win 7 Forum by mistake)


:: Checkinn.bat

mplay32 /play /close c:\flourish.mid

@echo off
cls



echo BACKUP STARTING, MAKE SURER YOU ARE ON THE MAIN SCREEN OF CHECKINN
Echo ...
echo ...
echo ...
echo PRESS 1 TO CONTINUE BACKUP (DO NOT PRESS 1 UNTIL YOU FINISH USING CHECKINN)
ECHO ...
ECHO ...
ECHO ...
echo PRESS 1 AND HIT ENTER WHEN READY

set /p x=

if %x% ==1 (goto :NEXT) ELSE (GOTO :END1)


:BEGINING
:NEXT


@echo off
start /w c:\Eventcorder\Eventcorder.exe -a -fC:\Eventcorder\Takes\ExitCheckInn.ecf
cls

echo.&echo.&echo.&echo.&echo.&echo.&echo.
echo PLEASE WAIT FOR BACKUP TO COMPLETE...



echo.&echo.&echo.&echo.&echo.&echo.&echo.
echo PLEASE WAIT FOR BACKUP TO COMPLETE...


setlocal enabledelayedexpansion


:: Create/run vbs file (extracts date components) & set variables..

set vbsfile=%temp%\newdate.vbs
echo Newdate = (Date())>%vbsfile%
echo Yyyy = DatePart("YYYY", Newdate)>>%vbsfile%
echo Mm = DatePart("M" , Newdate)>>%vbsfile%
echo Dd = DatePart("D" , Newdate)>>%vbsfile%
echo Wd = DatePart("WW" , Newdate)>>%vbsfile%
echo Wn = DatePart("Y" , Newdate)>>%vbsfile%
echo Ww = datepart("W" , Newdate)>>%vbsfile%

echo Wscript.Echo Yyyy^&" "^&Mm^&" "^&Dd^&" "^&Wd^&" "^&Ww^&" "^&Wn>>%vbsfile%

FOR /F "tokens=1-6 delims= " %%A in ('cscript //nologo %vbsfile%') do (
set weekday#=%%E
)
del %vbsfile% & set vbsfile=


for /f "tokens=1-3 delims=: " %%A in ('time/t') do (
set hour=%%A
set mins=%%B
set ampm=%%C
)
set hourmins=%hour%%mins%

: Set shift identifier based on time of day:

set shift=A

if "%ampm%"=="PM" if %hourmins% gtr 0200 if %hourmins% lss 1001 (
set shift=B & goto next
)

if "%ampm%"=="PM" if %hourmins% gtr 1000 if %hourmins% lss 1201 (
set shift=C & goto next
)

if "%ampm%"=="AM" if %hourmins% lss 0401 (
set shift=C
set /a weekday# -=1
if !weekday#! lss 1 set weekday#=7 & goto next
)

if "%ampm%"=="AM" if %hourmins% gtr 1159 (
set shift=C
set /a weekday# -=1
if !weekday#! lss 1 set weekday#=7
)

:next

:: Set alpha day from the week day number:

for /f "tokens=%weekday#%" %%a in ("Sun MON Tue Wed Thu Fri Sat") do (
set alfaday=%%a
)

:: Environment Variables set are:
:: %weekday#% = Day number within week (range 1 thru' 7, Sun is day #1)
:: %alfaday% = Alpha day (range Sun thru' Sat)
:: %hour% = Hour of the day
:: %mins% = Minutes of the hour
:: %ampm% = AM or PM indicator
:: %shift% = Shift identity letter ( range A thru C)

:: Xcopy FILES for backup.

set outpath=E:\CheckInn_%alfaday%_%shift%

if not exist %outpath% md %outpath%


xcopy C:\CheckInn\*.* %outpath% /D /E /C /R /H /I /K /Y/Q > nul



cls


echo.&echo.&echo.&echo.&echo.&echo.&echo.
echo BACKUP DONE - CHECKIN IS STARTING NOW...

start c:\checkinn\checkinn.exe
start /w c:\Eventcorder\Eventcorder.exe -a -fC:\Eventcorder\Takes\StartCheckInn.ecf
goto END

:END1
cls
echo.&echo.&echo.&echo.&echo.&echo.&echo.
echo ARE YOU SURE YOU DO NOT WANT TO DO BACKUP?
ECHO ...
ECHO ...
ECHO PRESS 1 TO DO BACKUP OR PRESS 9 TO EXIT.
ECHO ...
ECHO HIT ENTER WHEN READY

set /p y=


if %y% ==1 (goto :NEXT) else (GOTO :END)


:END
taskkill /F mplay32.exe

EXIT
It won't "work" in any OS.
I made an error above; I thought the IF tests were wrongly coded (space before ==) but in fact they work. Please ignore.
Hello Everybody,


I am wondering if this batch file can be modified to use the last backup it did in case of Hard drive failure or crash?

Thank you




Discussion

No Comment Found