decrpt.bat:
@echo off
Set WEB_CONFIG_PATH=D:\webconfig
Set DotNetPath=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
::Copy to local folder
copy %WEB_CONFIG_PATH%\Web.config Web.config /Y
:: Decrypt local Web.config
%DotNetPath%\aspnet_regiis -pdf "system.web/identity" %cd%
%DotNetPath%\aspnet_regiis -pdf "connectionStrings" %cd%
%DotNetPath%\aspnet_regiis -pdf "appSettings" %cd%
:: Backup the decrypt web.config file
set datestr=%date:/=-%
set datestr=%datestr: =-%
Set BackupFileName=Web_Dec_%datestr%.config
copy Web.config %BackupFileName% /-Y
:: backup end
PAUSE
encrpt.bat:
@echo off
Set WEB_CONFIG_PATH=D:\webconfig
set keyContainerName=pm_WEB_CODE
set DotNetPath=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
:: Encrypt local file
%DotNetPath%\aspnet_regiis -pef "system.web/identity" %cd% -prov %keyContainerName%
%DotNetPath%\aspnet_regiis -pef "connectionStrings" %cd% -prov %keyContainerName%
%DotNetPath%\aspnet_regiis -pef "appSettings" %cd% -prov %keyContainerName%
:: Authorization
%DotNetPath%\aspnet_regiis -pa %keyContainerName% "Users"
:: Update the live file
move /Y Web.config %WEB_CONFIG_PATH%
PAUSE