I've seen a program called Devcon (http://en.kioskea.net/faq/sujet-1886-enable-disable-a-device-from-the-command-line) used for enabling and disabling hardware devices. I want to do the same hopefully with python.

I want to turn the internet connection off with a script. I can already do it with popen('ipconfig /release') but I want something more robust. Is there any modules or library's that allow me access to devices, or will I have to stick with popen()?

Its for my uncle. He wants to kick his daughter off-line so she can do her homework instead of wasting her life on myspace and facebook.

7 Years
Discussion Span
Last Post by Tech B

so does he want the thing to be able to turn things off from another computer?


Two module comes in mind.

Python Win32 Extensions.
Tim Golden's excellent WMI.

WMI has an excellent way of looking at many hardware settings,
but has limited support for changing many of them.

Try pypi to see if someone has make somthing for this.

Maybe better to find a network soultion(something like you have now)
So low level as disabling hardware devices can be a problem,but very few thing are impossible.

Edited by snippsat: n/a


I found WMI which does exactly what I need it to.
I convert the time to decimal form so i can copare numbers instead of strings. The "target" is in Virginia, and the website I found didn'y have Virginia, so I use Miami's time instead. Time.gov's site updates the times on the tables instead of using java to fill the tables from a database.

It is used to kick my kid cousin offline between given hours, because she wastes her time on facebook and myspace instead of doing her homework.

#Version 2
#Uses WMI to kill Mozzilla FireFox and Internet Exploder intead #releasing the ip adress

import urllib2, time, sys, string, locale, wmi

def cnvtime(t):
  tr = string.replace(t,':','.')
  ts = tr.split()
  ti = ts[0]
  M = ts[1]
  tf = locale.atof(ti)
  return tf, M

while 1:
  response = urllib2.urlopen('http://www.timeanddate.com/worldclock/custom.html?sort=1')
  html = response.read() 
  ri = html.index('Miami')#The site didn't have Virginia, so Miami is used.
  t = html[ri+4:ri+39]
  timeDate = t[28:]
  timeDate = cnvtime(timeDate)
  print timeDate
  if timeDate[0] >= 2.34 and timeDate[0] <= 2.36 and timeDate[1] == 'PM':
    for i in wmi.WMI().Win32_Process(Name="iexplore.exe"):
    for m in wmi.WMI().Win32_Process(Name="firefox.exe"):

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.