title: Using Python to Stop and disable remote server services
body: <p>I new to programming and the Python world and am seeking help and guidance.</p>
  
  <p>I am trying to write code to stop and disable windows services during maintenance. I want to disable a service to avoid any restart during maintenance window. </p>
  
  <p>I am able to stop it if I use "Net stop service" but when I use command "SC \servername stop " it is not working. Below is my code. </p>
  
  <p>This code is working fine with Net command but error when I replace same command with "SC \servername stop " </p>
  
  <pre><code>    #Connection and Service change code    
       connection= wmi.WMI(line, user=username, password=password)
       process_startup = connection.Win32_ProcessStartup.new()
       command='Net stop spooler' #Works but error cmd "SC \\servername stop 
       &lt;service&gt;" error
       command5= "Net start spooler" #works error in "SC \\servername config 
       &lt;service&gt; start=disabled"
       if tasks=='stop':
         process__id2, result = 
         connection.Win32_Process.Create(CommandLine=command, 
         ProcessStartupInformation=process_startup)
         process__id, result = 
         connection.Win32_Process.Create(CommandLine=command5, 
         ProcessStartupInformation=process_startup)
         print("job disabled")'
  </code></pre>
  
  <p>Thank you for help </p>