title: PSExec to execute sql scripts in SQL server of Remote machine
body: <p>How to create a batch file to connect to Remote desktop and launch Microsoft Sql server and run some scripts.
  I tried creating a batch file to connect to  using</p>
  
  <pre><code>@ECHO OFF
  mstsc /v:"SERVERNAME"
  </code></pre>
  
  <p>But i was not able to pass username and password 
  Can anyone advise on this.</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code> psexec \\remotemachine-u username -p password ipconfig
  </code></pre>
  
  <p>Above one connects me to the remote machine and prints its Ip details.</p>
  
  <p>Now I am trying to execute SQL script which is in D:\ of remote machine to execute in Microsoft SQL server (connection) in the remote machine.
  Is that possible.</p>