title: Using MsDeploy to deploy Windows Services with preSync command
body: <p>Is anyone successfully using MsDeploy for deploying windows services with a preSync runCommand? I've got it working using an Administrator account, but can't for the life of me get it working on a standard user account. Unfortunately I can't use integrated authentication (we're deploying to an external box), and the thought of our Administrator password sitting in plaintext in logs on our build server doesn't exactly make me feel too comfortable. For that matter, neither does any user credentials - but I can't see a way around that.</p>
  
  <p>The command I'm using is this:</p>
  
  <pre><code>"tools/deploy/msdeploy.exe" -verb:sync 
  -preSync:runCommand="tools\Deploy\PreSyncCommand.cmd",waitInterval=30000 
  -source:dirPath="C:\BuiltSourcePath" 
  -dest:computerName=https://server:8172/msdeploy.axd?site=dummysitename,userName=service-deploy,password=service-deploy-pass,authType=basic,dirPath="C:\DeployPath\"
  -allowUntrusted
  </code></pre>
  
  <p>with rules set up in IIS for the dummy site to allow the authentication for the service-deploy windows account, with contentPath and runCommand permissions (for the moment set to C:\ as it's not entirely clear whether this needs to be set to the temporary path that MsDeploy streams to, or the deployment path?). The service-deploy account also has full control of the target directory. I get the following back:</p>
  
  <pre><code>Performing '-preSync'...
  Info: Using ID '7a7d34a1-b5d8-49f1-960a-31c9cf825868' for connections to the remote server.
  Info: Using ID '4d0b910c-aca4-4640-84bd-3597d22d99d1' for connections to the remote server.
  Info: Updating runCommand (C:\TeamCity\buildAgent\work\aec989676b349656\tools\De
  ploy\PreSyncCommand.cmd).
  Warning: Access is denied.
  Warning: The process 'C:\Windows\system32\cmd.exe' (command line '/c "C:\Windows
  \ServiceProfiles\LocalService\AppData\Local\Temp\giz2t0kb.0ay.cmd"') exited with
   code '0x1'.
  </code></pre>
  
  <p>This happens even if the contents of PreSyncCommand.cmd is blank. The same command runs fine if I pass in Administrator credentials. I've tried using ProcessMonitor to check if anything's being denied access but can't see any - so I'm guessing it's still a MsDeploy authentication rule. There's nothing in WmSvc.log (debugging is enabled), nor in the event log.</p>
  
  <p>Any ideas? Thanks!</p>