0

In my .Net Application I want to encrypt the Connection String Configuration Section .

I have created the batch files which include the commands for encryption and decryption . But now business decided to build a small Windows Forms Application which would rather simplify the tasks for the admin . When the admin clicks on the encrypt button , the application should encrypt the file and when he wants to decrypt back , he will hit the decrypt back button alternatively.

But those commands need to be run with administrative privileges . How would I convert the commands stated below to .Net code and also make sure that they run with administrative privileges?

cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319

aspnet_regiis.exe -pc "CustomEncryptKeys" -exp

aspnet_regiis.exe -pa "CustomEncryptKeys" "NT AUTHORITY\NETWORK SERVICE"

aspnet_regiis -pef "connectionStrings" "C:\inetpub\wwwroot\ABC" -prov "CustomEncryptProvider"

Thanks in advance .

Ondrej Svejdar
  • 21,349
  • 5
  • 54
  • 89
StrugglingCoder
  • 4,781
  • 16
  • 69
  • 103
  • 2
    There are .NET classes and methods that can do this for you. That way you can incorporate the logic in your code. – Huske Sep 01 '15 at 06:41
  • 1
    So the question is about **Windows Forms**, not ASP.NET at all? And you are really asking how to edit a web.config file from a desktop application? BTW IIS Management Console already allows you to edit config settings – Panagiotis Kanavos Sep 01 '15 at 07:02
  • Look to Process.Start for executing shell commands, for the win form app to be run under admin privileges it must have correct manifest (see http://stackoverflow.com/questions/1850768/how-to-give-my-c-sharp-app-administrative-rights-manifest-file) – Ondrej Svejdar Sep 01 '15 at 07:49
  • Could anyone of you please elaborate your answers ? I am having a difficult time implementing this. – StrugglingCoder Sep 01 '15 at 10:28

0 Answers0