title: Encrypting WebConfig
body: <p>I have a web application, which I publish to three web servers using the 'publish' option.</p>
  
  <p>I want to encrypt the connectionstrings section of the web config file.  The command below will do it:</p>
  
  <pre><code>c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef "connectionStrings" c:\inetpub\application
  </code></pre>
  
  <p>However, I have to RDP (Remote Desktop) to each server and run the command on each server as you cannot run it like this (from a client PC):</p>
  
  <p>\servername\c$\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef "connectionStrings" \servername\c$\inetpub\application</p>
  
  <p>Is there a better way of doing this: perhaps:</p>
  
  <blockquote>
    <p>1) Execute a command line on the server after publishing 2) Use a
    build option in Visual Studio that allows you to execute a batch file
    after publishing is complete</p>
  </blockquote>