Read INI file from Batch file

April 11, 2012 at 03:55:32
Specs: Windows 7
hi there im looking for some help if possible. I've made the script that starts the windows backup and places the backup image in a new folder once completed. I want to be able to read in an INI file for the "drives to include" and "unc network path".

Cant seem to get it to read from the ini correctly. if i manually enter the "include" and "backupshare" variables into the batch file it works. Could someone have a look please. heres the script

@echo off
:: backup.cmd
:: Backup using WBADMIN.EXE

for /f "tokens=1,2 delims==" %%a in (ini.ini) do (
if %%a==backupshare set backupshare=%%b
if %%a==include set include=%%b

echo %backupshare%
echo %include%

rem backup share UNC
set backupshare=%backupshare%

rem files and folders to include
set include=%include%

rem define date time variables for building the folder name
set m=%date:~6,2%
set d=%date:~3,2%
set y=%date:~9,4%
rem set h=%time:~0,2%
rem set min=%time:~3,2%
rem set sec=%time:~6,2%

rem defining a new folder like \\\\\
set newfolder=%backupshare%\%computername%\%d%%m%%y%
echo Creating %newfolder%

mkdir %newfolder%

rem run the backup
echo Backing up %include% to %newfolder%
wbadmin START BACKUP -backuptarget:%newfolder% -include:%include% -allCritical -vssFull -quiet


and heres the INI file ive been using


Thanks for your time

See More: Read INI file from Batch file

Report •

April 11, 2012 at 05:19:49
Leave echo off, and post the output. 80% chance cmd's not finding the ini file.

How To Ask Questions The Smart Way

Report •

April 11, 2012 at 05:42:46
Well in..that fixed it.

Thanks for that mate

Report •

Related Solutions

Ask Question