我使用wmi moudle,尝试改变我自己的计算机IP地址没有成功,它似乎没有任何错误,但IP地址没有改变
我已经检查过是否有多个适配器,但我只有一个import wmi
# Obtain network adaptors configurations
nic_configs = wmi.WMI().Win32_NetworkAdapterConfiguration(IPEnabled=True)
# First network adaptor
try:
nic = nic_configs[0]
except Exception as e:
raise Exception("חבר קודם את המחשב למתג!")
# IP address, subnetmask and gateway values should be unicode objects
ip = u'192.168.43.99'
subnetmask = u'255.255.0.0'
gateway = u'15.0.0.254'
# Set IP address, subnetmask and default gateway
# Note: EnableStatic() and SetGateways() methods require *lists* of values to be passed
print nic.EnableStatic(IPAddress=[ip],SubnetMask=[subnetmask])
print nic.SetGateways(DefaultIPGateway=[gateway])
输出:
^{pr2}$
编辑:我想它应该不在管理员下运行,我怎样才能让它自动运行?在