title: How to execute 'netsh' command through subprocess.check_output()
body: <p>I am running a batch file which in turn runs a python file. I want to execute netsh command to change the IPv4 settings from static to dhcp and vice versa. </p>
  
  <p>When I run the below code it executes and returns without any error</p>
  
  <pre><code>import subprocess
  cmd = "netsh interface ip show config"
  output = subprocess.check_output(cmd)
  print output
  </code></pre>
  
  <p>But when I execute the this piece of code through a batch file the python file exits with exit status 1. </p>
  
  <pre><code>import subprocess
  cmd = '''netsh interface ip set address "Local Area Connection 9" dhcp'''
  output = subprocess.check_output(cmd)
  print output
  </code></pre>
  
  <p>And It throws an error </p>
  
  <blockquote>
    <p>Python: can't open file 'Update_DHCP.py': [Errno 2] No such file or directory</p>
  </blockquote>
  
  <p>The python file and the batch file are in same folder and as per my understanding of updating the dhcp Ip, requires admin rights. I am even running the .bat file as 'Run as Administrator' but got the error [Errno 2]</p>
  
  <p>I have also tried to create a task using task scheduler to grant admin rights to the .bat file and run it. But still, it din't work for me.</p>
  
  <p>Can any one help me execute the command using subprocess.check_output() as I want to use the output returned by the check_output() call. Any help would be appreciated.</p>
  
  <p>I am working on Windows and my python version is 2.7</p>