Run command line code using code behind


Hi guys,

You may have face incidence like ruining a code segment using code behind, so check this code.
It use fro encrypt web config file connection string section by code behind executing comman line code

Command line code is:
aspnet_regiis.exe -pef “connectionStrings” C:\Projects\DemoApplication

So it can be run by code:

            var psi = new ProcessStartInfo(<aspnet_regiis.exe location>)
                {
                    Arguments = @"-pef ""connectionStrings"" "+'"'+<web config file location>+'"'+"",
                    UseShellExecute = false,
                    RedirectStandardOutput = false

                };
                Process.Start(psi);

cheers.


No comments:

Post a Comment