{"id":10137,"date":"2021-12-05T05:36:26","date_gmt":"2021-12-05T05:36:26","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=10137"},"modified":"2021-12-05T05:36:56","modified_gmt":"2021-12-05T05:36:56","slug":"read-ini-file-from-batch-file","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/read-ini-file-from-batch-file\/27752.html","title":{"rendered":"Read INI File From Batch File"},"content":{"rendered":"<p>hi there im looking for some help if possible. I&#8217;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 &#8220;drives to include&#8221; and &#8220;unc network path&#8221;.<\/p>\n<p>Cant seem to get it to read from the ini correctly. if i manually enter the &#8220;include&#8221; and &#8220;backupshare&#8221; variables into the batch file it works. Could someone have a look please. heres the script<\/p>\n<p>@echo off<br \/>\n:: backup.cmd<br \/>\n:: Backup using WBADMIN.EXE<\/p>\n<p>for \/f &#8220;tokens=1,2 delims==&#8221; %%a in (ini.ini) do (<br \/>\nif %%a==backupshare set backupshare=%%b<br \/>\nif %%a==include set include=%%b<br \/>\n)<\/p>\n<p>echo %backupshare%<br \/>\necho %include%<\/p>\n<p>rem backup share UNC<br \/>\nset backupshare=%backupshare%<\/p>\n<p>rem files and folders to include<br \/>\nset include=%include%<\/p>\n<p>&nbsp;<\/p>\n<p>rem define date time variables for building the folder name<br \/>\nset m=%date:~6,2%<br \/>\nset d=%date:~3,2%<br \/>\nset y=%date:~9,4%<br \/>\nrem set h=%time:~0,2%<br \/>\nrem set min=%time:~3,2%<br \/>\nrem set sec=%time:~6,2%<\/p>\n<p>rem defining a new folder like \\\\\\\\\\<br \/>\nset newfolder=%backupshare%\\%computername%\\%d%%m%%y%<br \/>\necho Creating %newfolder%<\/p>\n<p>mkdir %newfolder%<\/p>\n<p>rem run the backup<br \/>\necho Backing up %include% to %newfolder%<br \/>\nwbadmin START BACKUP -backuptarget:%newfolder% -include:%include% -allCritical -vssFull -quiet<\/p>\n<p>pause<\/p>\n<p>and heres the INI file ive been using<\/p>\n<p>backupshare=10.11.13.5\/test\/<br \/>\ninclude=c:<\/p>\n<p>Thanks for your time<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":8},"question-category":[55],"question_tags":[],"class_list":["post-10137","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/10137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=10137"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=10137"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=10137"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=10137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}