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 8093089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:25:42+00:00 2026-06-05T20:25:42+00:00

Observe the following Python script, Script.py: import subprocess src_directory = ‘Z:\z_7z\Some_Directory’ zip_file_name = ‘Test.7z’

  • 0

Observe the following Python script, “Script.py”:

import subprocess
src_directory = 'Z:\z_7z\Some_Directory'
zip_file_name = 'Test.7z'
cmd = ['7z', 'a', zip_file_name, src_directory, '-mx9']
subprocess.Popen(cmd, stderr = subprocess.STDOUT, stdout = subprocess.PIPE)

My intent is to schedule a Python script using Windows Task Scheduler. I have successfully done this using other Python scripts before. However, I am unable to execute the script shown above via scheduling. I am unsure as to whether this is a Windows Task Scheduler problem or a Python problem, but here is what I know:

“Script.py”, as shown above, is a script for running a 7zip compression on a “Some_Directory” directory. The script itself and the 7z.exe application which it is invoking are both stored in the “Y:\z_7z” directory.

The script seems to be working fine when executed manually. I can double-click on the script and it will execute properly. Also, I can execute the script from the command line via the following command:

Y:\z_7z\Script.py

However, I cannot execute the script manually by navigating to the “C:\Python27” directory and attempting the following:

python Y:\z_7z\Script.py

This yields the following error:

Line 5 in module subprocess.Popen(cmd, stderr = subprocess.STDOUT, ...)
WindowsError: [Error 2] The system cannot find the file specified

Provided all of that information, the real problem I am having is that Windows Task Scheduler cannot execute this script (Last Run Result = 0x1). I have tried various Windows Task Scheduler configurations, including the one which seems to be ideal which goes as follows:

  • Program/script: “C:\Python27\python.exe”
  • Add arguments (optional): “Y:\z_7z\Script.py”
  • Run whether user is logged on or not

Again, I have scheduled other Python scripts before which have run successfully. This Windows Task Scheduler task seems to be configured properly. I browsed through some of the more advanced settings and did not find anything suspicious with this particular task.

  • 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-06-05T20:25:44+00:00Added an answer on June 5, 2026 at 8:25 pm
    1. Don’t just launch 7z. Provide the full path to the executable.

      cmd = [r’C:\Program Files\7zip\7z.exe’, ‘a’, zip_file_name, src_directory, ‘-mx9’]
      Would work, considering that C:\Program Files\7zip\7z.exe is the executable path.

    2. Try not running the python process with the script as an argument. Run the python script itself.

    3. Your zip_file_name is relative. I’m not sure the argument is a filename. It may be a path. In that case, the .7z file may be created on C:\Windows\System32. To fix it, set zip_file_name to be a full path.

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

Sidebar

Related Questions

Observe the following piece of an msbuild script: <ItemGroup> <R Include=-Microsoft.Design#CA1000 /> <R Include=-Microsoft.Design#CA1002
Observe the following program written in Java (complete runnable version follows, but the important
I observe the following strange behaviour in Vim 7.3: When I'm below a fold,
I'm using the new print from Python 3.x and I observed that the following
Observe the following definition of a thread subclass (the entire runnable Java source file
Let's observe the following segment of code in Java that uses System.currentTimeMillis() in a
I have the following prototype JavaScript code Event.observe( window, 'load', function() { Event.observe( 'agreement',
I am trying to replot the following figure in a more legible way. Observe
Observe the following simple source code: using System; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit;
Observe the following screenshot: How do I anchor UIView a few pixel off the

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.