{"id":15437,"date":"2021-12-19T03:02:53","date_gmt":"2021-12-19T03:02:53","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=15437"},"modified":"2021-12-19T03:03:47","modified_gmt":"2021-12-19T03:03:47","slug":"batch-labels-in-a-for-loop","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/batch-labels-in-a-for-loop\/23251.html","title":{"rendered":"Batch Labels In a For Loop"},"content":{"rendered":"<p>I have been using a scripting solution that was provided to me by nbrane and it&#8217;s perfect for what I need. I use it ALL the time because it is awesome!!<br \/>\nIt looks like this:<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-Begin Script&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>@Echo Off<br \/>\nfor \/f %%a in (\\\\Server1\\apps$\\Scripts\\CompList\\Computers-ON.txt) do (<br \/>\necho processing to computer %%a<\/p>\n<p>(Commands for each computer go here)<\/p>\n<p>::&#8212;&#8212;&#8211;End<br \/>\n)<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-End Script&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>However, now I have another twist. I need to add some decision logic to the script. I&#8217;ve found some code that will determine the version of the O\/S, and now I need a: GoTo WinXP or GoTo Win7 However, when I add the label :WinXP or :Win7 ,the script will not run&#8212;Error: &#8220;The syntax of the command is incorrect.&#8221;<\/p>\n<p>This is the script that will NOT execute:<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-Begin Script&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>@Echo Off<br \/>\nfor \/f %%a in (\\\\Server1\\apps$\\Scripts\\CompList\\Computers-ON.txt) do (<br \/>\necho processing to computer %%a<\/p>\n<p>for \/f &#8220;tokens=2*&#8221; %%i IN (&#8216;reg query &#8220;HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion&#8221; \/v ProductName ^| Find &#8220;ProductName&#8221;&#8216;) DO set OSver=%%i %%j<\/p>\n<p>echo %OSver% | find &#8220;Windows XP&#8221; &gt; nul<br \/>\nif %ERRORLEVEL% == 0 GoTo Win_XP<\/p>\n<p>echo %OSver% | find &#8220;Windows 7&#8243; &gt; nul<br \/>\nif %ERRORLEVEL% == 0 GoTo Win_7<\/p>\n<p>:Win_XP<br \/>\nxcopy \/O \/Y \\\\Server1\\apps$\\Application\\Shortcut\\*.* \\\\%%a\\c$&#8221;\\Documents and Settings\\All Users\\Desktop\\*.*&#8221;<br \/>\nGoTo NextComp<\/p>\n<p>:Win_7<br \/>\nxcopy \/O \/Y \\\\Server1\\apps$\\Application\\Shortcut\\*.* \\\\%%a\\c$\\Users\\Public\\Desktop\\*.*<br \/>\nGoTo NextComp<\/p>\n<p>:NextComp<\/p>\n<p>)<\/p>\n<p>::&#8212;&#8212;&#8211;End<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-End Script&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>If I remove all of the labels (:WinXP, :Win7, :NextComp) the script will run&#8212;of course I get other errors, but that&#8217;s to be expected, since I don&#8217;t have the labels in there.<\/p>\n<p>Does anyone have any ideas or is more info needed?<\/p>\n<p>Thanks in advance!!! Any help is much appreciated.<\/p>\n<p>&#8212;&#8212;-Mark<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":35},"question-category":[55],"question_tags":[],"class_list":["post-15437","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\/15437","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=15437"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=15437"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=15437"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=15437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}