When I execute simple command like "net start", I am getting output successfully as shown below.
Python script:
import os
def test():
    cmd = ' net start  '
    output = os.popen(cmd).read()
    print output
test()
Output:
C:\Users\test\Desktop\service>python test.py
These Windows services are started:
   Application Experience
   Application Management
   Background Intelligent Transfer Service
   Base Filtering Engine
   Task Scheduler
   TCP/IP NetBIOS Helper
The command completed successfully.
C:\Users\test\Desktop\service>
But When I execute long commands (for example : "net start "windows search") I am NOT getting any output.
Python script:
import os
def test():
    cmd = ' net start "windows search"  '
    output = os.popen(cmd).read()
    print output
test()
Output:
C:\Users\test\Desktop\service>python test.py
C:\Users\test\Desktop\service>
I have tried "net start \"windows search\" ". also. But same issue.
Can anyone guide me on this please?
From the documentation:
Deprecated since version 2.6: This function is obsolete. Use the
subprocessmodule. Check especially the Replacing Older Functions with the subprocess Module section.
subprocess.Popen(['net', 'start', 'windows search'], ...)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With