title: Batch file: run command in a cmd.exe launched as a different user using batch file
body: <p>Hi Folks I am a newbie to batch files and I am facing a challenge. I have to do following steps using a batch file automatically. Steps 1 and 3 I am able to figure out, however for step 2 i need your help:</p>
  
  <p>A. Run command prompt using a user:</p>
  
  <p>Comment: This I have figured out, I can do it using: </p>
  
  <hr>
  
  <pre><code>            @Echo Off               
              runas /profile /savecred /user:xyzasa\asdasq "cmd"
  </code></pre>
  
  <hr>
  
  <p>B. Make some registry changes using the command prompt which opened in the previous step </p>
  
  <p>Comment: I know this can be done using the reg add command however when i am putting this command in the batch file it is not getting executed. Here is the current shape of my batch file:</p>
  
  <pre><code>            @echo off
              runas /profile /savecred /user:xyzasa\asdasq "cmd"
              reg add &lt;Machine Name&gt;&lt;Registry path and the changes to be made&gt;
  </code></pre>
  
  <p>C. Launch a rdp file</p>
  
  <p>Comment: This also I can do by simply mentioning the name of the rdp file as the last step.</p>
  
  <pre><code>            @echo off
              runas /profile /savecred /user:xyzasa\asdasq "cmd"
              reg add &lt;Machine Name&gt;&lt;Registry path and the changes to be made&gt;
              asd.rdp
  </code></pre>
  
  <p><strong>Question: How to make sure that after the cmd is launched as the result of the previous step the reg add command executes in the recently launched prompt?</strong></p>