473,246 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

how to set local ip address using python?

6
I want to set the ip, subnet mask, default gateway.
Could anyone here give me a suggestion?
thanks
Aug 31 '07 #1
3 10115
bartonc
6,596 Expert 4TB
I want to set the ip, subnet mask, default gateway.
Could anyone here give me a suggestion?
thanks
Welcome back! I suggest that you get the book:
Python Programming on Win32 By Mark Hammond and Andy Robinson 2000
There is a secret link given in the book for all kinds of pre-written scripts.

Alternatively, WMI may do the job. Microsoft has published example Python scripts using WMI here.

Or, you can access any win32 API using the ctyps module in that is standard in V2.5 and can be installed on earlier versions of Python.

And remember to include your OS in your post so people don't have to go searching through your posts. Thank you.
Aug 31 '07 #2
pydou
6
thanks
here is the code:
Expand|Select|Wrap|Line Numbers
  1. netobj = wmi.WMI().Win32_NetworkAdapterConfiguration( IPEnabled=True )
  2. returnValue = nic.EnableStatic(IPAddress=ip, SubnetMask=mask)
Sep 16 '07 #3
bartonc
6,596 Expert 4TB
thanks
here is the code:
Expand|Select|Wrap|Line Numbers
  1. netobj = wmi.WMI().Win32_NetworkAdapterConfiguration( IPEnabled=True )
  2. returnValue = nic.EnableStatic(IPAddress=ip, SubnetMask=mask)
Thank you for taking the time to dig up your thread. This is very helpful to every one.
Sep 16 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: John Morgan | last post by:
I have Enterprise Manager on my local machine. For the last twelve months it has been connecting without problem to my online SQL Server database provided by my ISP. Three weeks ago the ISP...
2
by: Mike:o | last post by:
I need to validate XML documents (orders) against their schema before processing. The PurchaseOrder schema that we use references 3 other schemas using the <imports ...> element. Here is the...
0
by: Gregory Hassett | last post by:
Hello, I want to periodically send a TCP packet to a peer, always from the same source port. That is, each packet will come from my local ip address, port 8801, and go to the peer's ip address,...
23
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people...
24
by: Daniel Crespo | last post by:
Hi, I tried: import ctypes import socket import struct def get_macaddress(host): """ Returns the MAC address of a network host, requires >= WIN2K. """
6
by: Brad | last post by:
I have a win2003 server workstation with multiple webs, each web has it's own ip address. In VS2005, if I select to open an existing web site, select Local IIS, the dialog correctly displays a...
4
by: Tom | last post by:
I come from C but don't really understand why in C++ you can return a temporary object from a function. For example: class Test { public: Test() { cout << "Address of object: " <<this...
5
by: Hooyoo | last post by:
Hi, here, How to get local machine name and IP address? Thanks.
1
by: jcprince | last post by:
Hi Not sure I can do what I'm trying to do without using a 3rd party component like Dart. I need to build a windows service to create a socket connection on an IBM mainframe using an IP and port...
7
by: RN1 | last post by:
Is it possible to connect to my local SQL Server 2005 database from a remote web server? If yes, what ConnectionString do I use? Thanks, Ron
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.