0

I have written a program in the last days which automatically changes the proxy server. This runs as a Windows Forms Tray Application on the user level. Now came a request which caused me some problems. A cmd command "ipconfig /registerdns" should be executed but this requires higher permissions. I'm now looking for a way to easily execute this command in normal user context. Is there a way to run this one command as a system? Or any other possibility?

Or is there another function to re-register the dns without admin priviledge?

I hope there is a easy way.

Thank you very much!

Shazy
  • 147
  • 1
  • 10

3 Answers3

1

As i know admin processes can only be created by another admin processes but still you can try adding this parameter to your process's start info

StartInfo.Verb = "runas";

if it doesnt work you set your application to run always as admin by adding app.manifest to your project and editing line 19 as below.

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
trksyln
  • 136
  • 10
1

Create a script (.cmd or .bat) containing required command (here: "ipconfig /registerdns"), then flag it as "Run as administrator". Finally, run this script from your app instead of original command. This should help in flagging as "Run as administrator": How to code a BAT file to always run as admin mode?

VillageTech
  • 1,968
  • 8
  • 18
0

Okay so I found no solution for my former problem, because it is not possible to launch a elevated command from a user Application. But I found a powershell command: Register-DnsClient. This command does the same and does not need elevated priviledges. Only downside is it works only on Windows 8.1 and newer. So Windows 7 is not supported.

Shazy
  • 147
  • 1
  • 10