Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Dec 2004
    Posts
    199

    Question DOS batch file question

    I have a data file, called myInput, in a directory called c:MyProject
    I have a python program, called myProcess, also in c:MyProject
    I want to run the batch file, also stored in c:Myproject
    The environment variable is set to point to c:\python32 which is where my python lives

    DOS BATCHFILE
    python process.py -i myInput.txt
    dir /w
    pause

    ERROR MESSAGE:
    When I run my batch file I get the error message "c: python was not found"

    The environment variable should have told it where to look for python surely?

    NOTE:
    If I copy MY DATA, PROGRAM and my BATCH file into c:\python32 directory it works! But I don't want to do that.

    Thanks in advance

    SYSTEM:
    W10

  2. #2
    Junior Member
    Join Date
    Dec 2004
    Posts
    199

    Default Re: DOS batch file question

    I found that this works...

    BATCHFILE
    c:\python32\python.exe process.py -i myInput.txt
    dir /w
    pause

    BUT it still doesn't explain why my environment variable doesn't work!

  3. #3
    Senior Member
    Join Date
    Sep 2007
    Location
    Lower Hutt, NZ
    Posts
    768

    Default Re: DOS batch file question

    What environment variable is set to c:\python?

    If itís pythonhome that doesnít help with Executing python from anywhere. You need to add c:\python to the PATH environment variable

  4. #4
    Enterprise IT Consultant chiefnz's Avatar
    Join Date
    Dec 2004
    Location
    Sydney AU
    Posts
    1,649

    Default Re: DOS batch file question

    Also make sure that the Python path is set under System Variables and NOT User Variables.

    Asus PRIME Z370-P
    Core i7-8700K
    Corsair Hydro H100x
    32GB DDR4 @ 3200MHz
    Intel 660P 512GB M.2 NVMe
    Crucial P1 1TB M.2 NVMe
    Crucial 512GB SSD
    Gigabyte RTX 2060 OC
    Corsair Crystal 460X
    EVGA SuperNOVA G+ 650W

  5. #5
    Senior Member 1101's Avatar
    Join Date
    Jan 2008
    Posts
    7,105

    Default Re: DOS batch file question

    path C:\python32

    smiley face is optional in DOS

    Better way(?) would be to add this to the start bat file

    CD\
    CD c:\python32

  6. #6
    Senior Member 1101's Avatar
    Join Date
    Jan 2008
    Posts
    7,105

    Default Re: DOS batch file question

    Quote Originally Posted by Billy View Post

    BUT it still doesn't explain why my environment variable doesn't work!
    from a cmd prompt, run
    path

    see whats actually in there

  7. #7
    Enterprise IT Consultant chiefnz's Avatar
    Join Date
    Dec 2004
    Location
    Sydney AU
    Posts
    1,649

    Default Re: DOS batch file question

    Quote Originally Posted by 1101 View Post
    path C:\python32

    smiley face is optional in DOS

    Better way(?) would be to add this to the start bat file

    CD\
    CD c:\python32
    I don't disagree with that, it is a "workaround" to the problem... the whole point behind "system paths" is to be able to "point the OS" to the correct locations for executable files/programmatic access etc... having to constantly add lines of "code" to a file to get to a path is not an efficient practice. Environment variables exist because "standard paths" for programming languages/compilers etc became "normal" over time.

    Asus PRIME Z370-P
    Core i7-8700K
    Corsair Hydro H100x
    32GB DDR4 @ 3200MHz
    Intel 660P 512GB M.2 NVMe
    Crucial P1 1TB M.2 NVMe
    Crucial 512GB SSD
    Gigabyte RTX 2060 OC
    Corsair Crystal 460X
    EVGA SuperNOVA G+ 650W

Similar Threads

  1. batch file help
    By Mike in forum PressF1
    Replies: 4
    Last Post: 14-07-2011, 09:16 AM
  2. Batch file help please
    By johcar in forum PressF1
    Replies: 4
    Last Post: 18-11-2006, 08:04 PM
  3. Batch File Help
    By Kodaz in forum PressF1
    Replies: 5
    Last Post: 01-12-2004, 12:07 PM
  4. My batch file
    By Blue_face in forum PressF1
    Replies: 2
    Last Post: 15-01-2004, 11:29 PM
  5. Help with a batch file
    By Caesius in forum PressF1
    Replies: 6
    Last Post: 10-07-2003, 04:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •