Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 6th, 2008, 04:57 AM
Registered User
Join Date: Mar 2008
Location: chennai, Tamil Nadu, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Issue of changing IPAddress programatically in win

My requirement is to change the IP Address of local system programatically using .net.
IP Address should change to, subnet mask =, default gateway=

I have created a small C# Console application in Visual Studio 2005 which change the IP address of the local system. I execute the following batch file using Process.Start("ipchange1.bat");

Content of batch file is:

set path=c:\Windows\System32
netsh interface ip set address name="Local Area Connection" static 1

The above application is not working in Vista. It showed the error message as "The requested operation requires elevation".
To solve this error I added a new file to the project entitled ipApplication.exe.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
   <assemblyIdentity version="" processorArchitecture="X86" name="ipApplication" type="win32"/>
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
            <requestedExecutionLevel level="requireAdministrator"/>

I embeded the manifest into my executable by adding the below code in Project Properties -> Build Events -> Post-build event command line

"$(DevEnvDir)..\..\SDK\v2.0\bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" –outputresource:"$(TargetDir)$(TargetFileName)"; #1

when I click on the generated exe file in bin/Debug it is working fine, but I need to run this application at the end of the installation of a setup package. I added the exe file in Commit part of Custom Action.

At the end of installation I got an error 2869.

I solved the issue by getting help from this link:

The program is working fine at the end of installation but, It is changing the IP Address abnormally
The changed IP Address is, Subnet Mask=, Default Gateway=

I don't know how to proceed further can anyone guide me with the above issue or do anyone have an alternate solution??

Need your kind support

Thanks and Regards,

  #2 (permalink)  
Old March 6th, 2008, 05:55 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma

There seem to be a problem in the batch file. try removing "name=" from this

netsh interface ip set address name="Local Area Connection" static 1

so that it reads

netsh interface ip set address "Local Area Connection" static 1


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Events issue for programatically created GridView VadimZ ASP.NET 2.0 Professional 4 July 5th, 2007 05:11 PM
Accessing Programatically xlr8 BOOK: Beginning C# 2005 Databases 1 April 30th, 2007 08:56 AM
Obtain Primary IPAddress acuze C# 2005 0 July 27th, 2006 12:33 AM
Win '98 vs. Win XP rgerald Access VBA 0 February 19th, 2004 12:30 PM

All times are GMT -4. The time now is 10:36 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.