1
wmi moudle을 사용하고 내 컴퓨터 IP 주소를 아무런 성공없이 변경하려고 시도하면 실행 중 오류가없는 것 같지만 IP 주소는 변경되지 않은 것 같습니다 이미 i 어쩌면 여러 어댑터가하지만 난 단 하나의set ip address python
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])
출력이 있습니다
(-2147024891,)
(67,)
편집 : 나는 인해 adminstrator에서 실행, 내가 어떻게이 adminstrator에 의해 자동으로 실행되도록 할 수 없습니다 그것의 생각?