{"id":13538,"date":"2021-12-13T11:20:55","date_gmt":"2021-12-13T11:20:55","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=13538"},"modified":"2021-12-13T11:21:41","modified_gmt":"2021-12-13T11:21:41","slug":"vbs-within-hta-plink","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/vbs-within-hta-plink\/21045.html","title":{"rendered":"VBS (Within HTA) Plink"},"content":{"rendered":"<p>Hi,<br \/>\nI have been working on a script, part of which will use plink (command line version of putty, used for making ssh connections)<br \/>\nto connect to a remote server run a command and return the result to a text area within the HTA.<br \/>\nThis works fine if i have connected to the server before, but if i havent it will hang because it is not getting a response to the y\/n question of storing the host keys.<br \/>\nTo get around this i thought i could open a cmd prompt and run plink from there, thus giving me sort of an interactive session, so that if they key was known, the user would not be prompted, but if the host key was not know, the dos box would show the message about accepting the host key, and once you type yes or no the command that you passed to plink via the command line is executed.<br \/>\n(at first i thought i would use putty, but it does not allow you to pass a comaand as a commandline variable like plink does)<br \/>\nThe issue i have is that when the script runs plink, the dos box pops up but then it hangs there, and my textarea is populated with<br \/>\n&lt;code&gt;<br \/>\nC:\\Documents and Settings\\%USERNAME%\\Desktop\\test\\VB work\\VBS work\\VBS text&gt;<br \/>\n&lt;\/code&gt;<br \/>\nWhich is just the local path of my HTA.<br \/>\nThe command works fine when i use it manually with the command line.<br \/>\nCan anyone see whats going wrong?<br \/>\n&lt;code&gt;<br \/>\nSub Plink<br \/>\ntilltext.Value = &#8220;Checking Connection Status&#8230;&#8221;<br \/>\nRefresh<br \/>\nconnect = &#8220;0&#8221;<br \/>\nCall TillPing(strdata2)<br \/>\nIf connect = &#8220;1&#8221; then<br \/>\ntilltext.Value = &#8220;Running Command&#8221;<br \/>\nSet objShell1 = CreateObject(&#8220;WScript.Shell&#8221;)<br \/>\nSet objWshScriptExec1 = objShell1.exec(&#8220;cmd \/K &#8221; &amp; Chr(34) &amp; &#8220;C:\\Program Files\\Putty\\plink&#8221; &amp; Chr(34) &amp; &#8221; -ssh&#8221; &amp; strdata2 &amp; &#8221; -l MYUSER -pw MYPASS &#8221; &amp; strplinkcmd)<br \/>\nSet objStdOut1 = objWshScriptExec1.StdOut<br \/>\nstrOutput1 = objStdOut1.ReadAll<br \/>\nTillText.value = strOutput1<br \/>\nRefresh<br \/>\nElse<br \/>\nEnd If<br \/>\nEnd Sub<br \/>\n&lt;\/code&gt;<\/p>\n<p>strdata2 = a variable that hold machine name<br \/>\nstrplinkcmd = a linux command<\/p>\n<p>Thanks in advance<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":0},"question-category":[55],"question_tags":[],"class_list":["post-13538","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\/13538","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=13538"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=13538"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=13538"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=13538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}