title: Exit Cmd window after execution of script in VBA
body: <p>I would like to Exit the CMD window after execution of script (currently I am exiting CMD manually by writing exit in the CMD window, after which VBA continues running)</p>
  
  <pre class="lang-vb prettyprint-override"><code>Dim wsh As Object
  Set wsh = VBA.CreateObject("WScript.Shell")
  Dim waitOnReturn As Boolean: waitOnReturn = True
  Dim windowStyle As Integer: windowStyle = 1
  Dim errorCode As Long
  errorCode = wsh.Run(sCmdline, windowStyle, waitOnReturn)
  
  '-- Finally Run function Arguments ----- 
   errorCode = wsh.Run("cmd /k systeminfo &gt;D:\Tools\MyScript\SystemInfo.txt", windowStyle, waitOnReturn)
  
  If errorCode = 0 Then
      MsgBox "Done! No error to report."
      Set wsh = Nothing
  Else
      MsgBox "Program exited with error code " &amp; errorCode &amp; "."
      Set wsh = Nothing
  End If
  </code></pre>