tags:

views:

47

answers:

1

I have the application which needs a permanent Internet connection. But sometimes we have difficulty with our provider. In this case it needs to be switched on a reserve channel. In our network we just change a gateway address. Now I want to automate this action. So, how can I change the gateway in Windows programmatically? And are there any ways to avoid showing an UAC alerts on Vista?

A: 

So, how can I change the gateway in Windows programmatically?

One possible route is using the WMI APIs to programmatically set network settings. Have a look at this Codeproject.com article for more information.

Another route is building an app that silently launches the built-in Windows tool netsh.exe. You can specify command line arguments to change the settings for your network connection, IIRC.

You can read more about this in Microsoft's knowledge base article: How to Use the Netsh.exe tool and command line switches.

And are there any ways to avoid showing an UAC alerts on Vista?

No. Changing the network settings is something only an adminstrator should do. You must launch your app with admin privs. You can tell Vista (and Windows 7 and future OSes) that your app needs admin privs, see Create and embed a UAC application manifest.

Judah Himango