I am trying to set my IP address to a specific one on a LAN Network.
To do this i have tried using the following:
import subprocess
command='netsh interface ipv4 set address name="Local Area Connection* 4" source=static address=192.168.173.234 mask=255.255.255.0 gateway=192.168.0.1'
subprocess.call(["cmd.exe", command])
The only thing this results in is the starting up of an empty cmd.exe that isn't doing anything.
Also, what for would the shell=True be used ? When I try to use it, python returns a SyntaxError
UPDATE: If I use:
command='netsh interface ipv4 set address name="Local Area Connection* 4" source=static address=192.168.173.222 mask=255.255.255.0 gateway=192.168.0.1'
subprocess.check_call(["netsh.exe", command])
Python Returns the error:
Traceback (most recent call last):
File "D:file path", line 8, in <module>
subprocess.check_call(["netsh.exe", netsh_cmd])
File "C:\Python27\lib\subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['netsh.exe', 'netsh interface ipv4 set address name="Local Area Connection* 4" source=static address=192.168.173.222 mask=255.255.255.0 gateway=192.168.0.1']' returned non-zero exit status 1