title: Elevated privileges required for MsDeploy runCommand?
body: <p>I'm attempting to use MsDeploy runCommand provider to uninstall and reinstall a Windows service during an automated deployment.</p>
  
  <p>So far, I've been somewhat successful when following the advice in <a href="https://stackoverflow.com/questions/4380819/msdeploy-runcommand-priviliges">this question</a> and <a href="http://blog.muonlab.com/2010/09/13/remote-deployments-with-msdeploy/" rel="nofollow noreferrer">this blog post</a>.</p>
  
  <p>To perform the actual install/uninstall operations, I'm calling a batch file on the remote host.  The batch file works as expected when I log into the host directly and use the 'Run as Administrator' option from the shell.  When simply running the batch file by double-clicking (or when running the batch file with the MsDeploy runCommand provider), the batch file doesn't have sufficient permissions to perform the install or uninstall operation.  In all cases, I'm running the batch file with a user account that is a local administrator on the host.</p>
  
  <p>I've confirmed that runCommand is using an administrator account through the Management Service Delegation tool, and restarted the Management Service just for the heck of it.</p>
  
  <p>My questions know are:</p>
  
  <p>1) How can I emulate the 'Run As Administrator' with the runCommand provider?</p>
  
  <p>2) If I use a Powershell script instead of a batch file, would this still be a problem?</p>
  
  <p>3) Is there something basic I'm missing here?</p>
  
  <p>I would really not have to write real software to perform this action on the remote host!</p>
  
  <p>Any advice would be appreciated.</p>