Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6907501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:26:35+00:00 2026-05-27T08:26:35+00:00

I have a simple batch file here which will print a word document from

  • 0

I have a simple batch file here which will print a word document from the command line.

"C:\Program Files\Microsoft Office\Office12\winword.exe" "p:\docs\daily checks.doc" /mFilePrintDefault /mFileExit

I am trying to place this into a python script, I have managed to get the document to open by using

subprocess.Popen('"C:\\Program Files\Microsoft Office\Office12\winword.exe"' '"P:\\docs\\daily checks.doc "')

I can’t seem to get the /mFilePrintDefault /mFileExit part in the command, I have tried using +'"/mFilePrintDefault /mFileExit"' plus without the +, but then the document won’t open.

Can you possibly help to see how I can print this word document, or is there a better way

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:26:36+00:00Added an answer on May 27, 2026 at 8:26 am

    This should work:

    subprocess.Popen(["C:\\Program Files\Microsoft Office\Office12\winword.exe", "P:\\docs\\daily checks.doc", "/mFilePrintDefault", "/mFileExit"]).communicate()
    

    Or, altenatively,

    subprocess.Popen("'C:\\Program Files\Microsoft Office\Office12\winword.exe' 'P:\\docs\\daily checks.doc' /mFilePrintDefault /mFileExit", shell=True).communicate()
    

    When you use shell=True the command is executed through a shell. This means that you have to pass a single string the same way as you would write the command in a shell, that is, with the quotes to prevent arguments with spaces to be splitted.

    When you use shell=False (the default value), the command isn’t executed through a shell. This means that you’ve to split the arguments yourself. The way you do this, is passing a list with all the arguments. In this case, no extra quoting is needed because the list elements already provide this information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple SSIS package which reads data from flat file and insert into
Is it possible to run any Command Line based program or batch file and
I have simple SSIS package where I import data from flat file into SQL
I have made a simple batch file for backing up my repository changes and
I have a simple batch file that executes BTSTask ImportBindings on a previously exported
I'm running a simple batch file which is generated by a vbscript to delete
i have a simple batch file that i would like to be able to
Currently I have a one line batch file to back up a file. I
I'd like to write a simple batch file to copy a few files around.
For example, suppose I have a batch file called 'test.cmd' and it simply contains:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.