Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,109 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,699 people online right now. Registration is fast and FREE... Join Now!




Netsh Interface

 
Reply to this topicStart new topic

Netsh Interface

MikeAbyss
29 Nov, 2007 - 09:12 PM
Post #1

New D.I.C Head
Group Icon

Joined: 9 Jul, 2007
Posts: 9


Dream Kudos: 25
My Contributions
I'm trying to use
CODE

System.Diagnostics.Process.Start("netsh interface ip set address name=\"LAN1\" static 10.0.0.1 255.255.255.0");


What I'm trying to do is create a button that changes the users IP to 10.0.0.1

but it doesn't seem to work, anyone know the correct way of writing it?

The error I get is a runtime error, Win32 Exception was unhanded.

Thanks to all who replies
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Netsh Interface
29 Nov, 2007 - 09:30 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8600
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Try putting it into a Try...Catch block and see if it tells you the error:

NOTE: Also, try adding using System.Diagnostics; to the top of your class so you dont have to type all that out.

CODE

try
{
       Process.Start("netsh interface ip set address name=\"LAN1\" static 10.0.0.1 255.255.255.0");
}
catch(Exception ex)
{
       MessageBox.Show(ex.Message);
}


That should at least get you closer to your error. By the way, why are you writing an application that changes a users IP address?
User is offlineProfile CardPM
+Quote Post

MikeAbyss
RE: Netsh Interface
29 Nov, 2007 - 09:49 PM
Post #3

New D.I.C Head
Group Icon

Joined: 9 Jul, 2007
Posts: 9


Dream Kudos: 25
My Contributions
Thanks for the help, haven't got it working yet tho :X "The system cannot find the file specified" and it's for a project at school, I'm suppose to choose 1 other course that I'm currently taking, and use programming with it

E.g I have cisco(Networking) this semester, so I've decide to program an IP changer (Networking + Programming)

This post has been edited by MikeAbyss: 29 Nov, 2007 - 09:49 PM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Netsh Interface
29 Nov, 2007 - 09:54 PM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8600
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
That error is telling you that you're providing the wrong path to the specified file you're wanting to access
User is offlineProfile CardPM
+Quote Post

MikeAbyss
RE: Netsh Interface
29 Nov, 2007 - 11:20 PM
Post #5

New D.I.C Head
Group Icon

Joined: 9 Jul, 2007
Posts: 9


Dream Kudos: 25
My Contributions
Never mind, from what I've read this kind of functionality is still not supported by the framework sad.gif

This post has been edited by MikeAbyss: 29 Nov, 2007 - 11:35 PM
User is offlineProfile CardPM
+Quote Post

corliss
RE: Netsh Interface
9 Dec, 2007 - 10:06 PM
Post #6

D.I.C Head
Group Icon

Joined: 25 Oct, 2006
Posts: 119



Thanked: 1 times
Dream Kudos: 50
My Contributions
Yes, But it still can be acheived.
Find the paths that have the currnet ip address and change it. Then refresh the network settings on the device that you are interfacing like the NIC card.
Carry on soldier
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 09:28PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month