{"id":334,"date":"2021-09-03T19:59:36","date_gmt":"2021-09-03T19:59:36","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/programming-pass-a-variable-from-vbs-to-batch-25449-html"},"modified":"2021-09-03T19:59:36","modified_gmt":"2021-09-03T19:59:36","slug":"programming-pass-a-variable-from-vbs-to-batch-25449-html","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/pass-a-variable-from-vbs-to-batch\/25449.html","title":{"rendered":"Solved Pass a variable from VBS to batch"},"content":{"rendered":"<p><td>I am working on a batch script for my specific purpose.<br \/>The batch has launches a program like so:<\/p>\n<pre>start \/w program.exe %1<\/pre>\n<p>This way I can easily pass variable to my batch using a shortcut. Like:<\/p>\n<pre>C:mybatch.bat \"My variable\"<\/pre>\n<p>Because I the batch waits for the program to do its job, it could be open for extended periods of time. I find it annoying to have a batch constantly open, so looked for a way to hide it and settled on this short piece of VBS:<\/p>\n<pre>CreateObject(\"Wscript.Shell\").Run \"mybatch.bat\",0<\/pre>\n<p>This is is exactly what I needed and it makes things a lot easier, with one exception. While using this VBS, I can&#8217;t pass variables to my batch&#8230; or to be more precise don&#8217;t know how to.<br \/>My intention is to make several shortcuts with different variables like so:<\/p>\n<pre>C:start.vbs \"My variable\"<\/pre>\n<p>I want to be able to pass &#8220;My variable&#8221; to my batch, but still be able to manually launch start.vbs without any variable in a way that won&#8217;t pass a random variable if it is not defined. Passing a blank variable is fine.<br \/>I have tried searching for a solution on Google, but being a total newbie to VBS, I couldn&#8217;t find the right solution. Any help would be highly appreciated. Thanks in advance.\n<\/td><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","meta":{"inline_featured_image":false,"iawp_total_views":36},"question-category":[],"question_tags":[],"class_list":["post-334","question","type-question","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/334","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=334"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=334"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=334"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}