0

i want to format a drive using subprocess and getting the windows command prompt to pop-up to see the results, but when doing this:

subprocess.Popen(["FORMAT", drive, "/FS:FAT32", "/A:32K"], shell=True).communicate()

i get this error:

WindowsError: [Error 2] The system cannot find the file specified

any help?

3
  • 1
    you need shell=True I believe Commented Sep 12, 2012 at 17:02
  • oh, my bad, a typo when writing this... edited... Commented Sep 12, 2012 at 17:04
  • try using its real name instead maybe (format.com) Commented Sep 12, 2012 at 17:07

1 Answer 1

1
subprocess.Popen(["format.com", drive, "/FS:FAT32", "/A:32K"], shell=True).communicate()

you can find out by typeing where FORMAT in your cmd shell (not python shell ... obv.)

Sign up to request clarification or add additional context in comments.

4 Comments

(which should be in your %Path%)
i'm having more problems... if i set shell=true, it works but the command prompt window doesn't shows up, and the FORMAT command needs some user input after being executed :/
use subprocess.Popen(["cmd","/K","FORMAT SOME ARGS"]).communicate() or something like that...
if you put the full path to format.com you can set shell=False also

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.