title: How to run or install tool on hosted agent in VSTS
body: <p>I want to run cmd as an administrator on VSTS.</p>
  
  <p>Actaully I am trying to install git-tfs with chocolatey tool manager on VSTS hosted agent, So I am running the following command on VSTS command line task:</p>
  
  <p>@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('<a href="https://chocolatey.org/install.ps1" rel="noreferrer">https://chocolatey.org/install.ps1</a>'))" &amp;&amp; SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"</p>
  
  <p>or,</p>
  
  <p>Alternatively VSTS also provides the chocolatey task for installation, you can see this in the screenshot :</p>
  
  <p><a href="https://i.stack.imgur.com/PM3iE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PM3iE.png" alt="enter image description here"></a></p>
  
  <p>Both of the above approaches giving the same error:</p>
  
  <h2>[error]System.Management.Automation.RuntimeException: Installation of Chocolatey to default folder requires Administrative permissions. Please run from elevated prompt. Please see <a href="https://chocolatey.org/install" rel="noreferrer">https://chocolatey.org/install</a> for details and alternatives if needing to install as a non-administrator. ---> System.Management.Automation.RuntimeException: Installation of Chocolatey to default folder requires Administrative permissions. Please run from elevated prompt. Please see <a href="https://chocolatey.org/install" rel="noreferrer">https://chocolatey.org/install</a> for details and alternatives if needing to install as a non-administrator.</h2>