1
當我嘗試這樣做Python的WMI網絡適配器配置參數問題[Windows 8.1中] [Python 2.7版] [WMI 1.4.9]
SetDynamicDNSRegistration(True)
它返回 '68',我擡起頭來對MSDN WMI page這意味着「輸入參數無效」。
完整劇本
import wmi
nic_configs = wmi.WMI('').Win32_NetworkAdapterConfiguration(IPEnabled=True)
# First network adaptor
nic = nic_configs[0]
# IP address, subnetmask and gateway values should be unicode objects
ip = u'192.168.0.151'
subnetmask = u'255.255.255.0'
gateway = u'192.168.0.1'
dns = u'192.168.0.1'
# Set IP address, subnetmask and default gateway
# Note: EnableStatic() and SetGateways() methods require *lists* of values to be passed
a = nic.EnableStatic(IPAddress=[ip],SubnetMask=[subnetmask])
b = nic.SetGateways(DefaultIPGateway=[gateway])
c = nic.SetDNSServerSearchOrder([dns])
d = nic.SetDynamicDNSRegistration(True)
print(a)
print(b)
print(c)
print(d)
有什麼不對?我確定「True」是真正的布爾真正的Python語法......我甚至不知道......
會發生什麼? – Steve
完美,但我幾乎不能將評論標記爲已接受的答案...您是否將它寫成答案,以便我可以接受它? –