Schtasks not working properly, Windows 7

Page 1 of 3 123 LastLast

  1. Posts : 17
    Windows 7 Ultimate x64
       #1

    Schtasks not working properly, Windows 7


    Hi, I am making batch file program which monitors computer tasklist, openfiles and system variables every x minutes.

    This is my scheduled bat file, ks1.bat, which outputs openfiles to txt file:
    Code:
    @echo off
    cd..
    cd results
    md %date%
    cd %date%
    echo Computer detective is running...
    echo.
    echo Copying active files list...
    openfiles > Active_Files_List.txt
    echo Task completed. Detective closes...
    ping -n 3 127.0.0.1 >nul
    exit
    This is line in main batch which shedules to run this file:
    Code:
    cd ComputerDetective
    cd Tasks
    schtasks /create /sc minute /mo %minutes% /tn "Computer detective" /tr ks1.bat
    Problem is when ks1.bat is scheduled to run from main program, I see only ks1 cmd window splash and no commands are done. I also tried to schedule ks1 from desktop including full path, but then I get two lines which say The system cannot find the path specified and file or directory already exists.

    Please help me to solve this problem. Sorry for my bad english if it's so, I am from Lithuania. Thank you in advance.
    Last edited by neone; 22 Oct 2012 at 12:15.
      My Computer


  2. Posts : 6,285
    Windows 10 Pro X64
       #2

    What is %minutes% set to?

    I think you need to specify the full path to ks1.bat.

    /tr "c:\users\********\ks1.bat"

    Also, openfiles requires one or more parameters, something like this works for me:

    openfiles /query /s \\computername /v
      My Computer


  3. Posts : 17
    Windows 7 Ultimate x64
    Thread Starter
       #3

    %minutes% is set to user entered minutes. I want to avoid full path to ks1, because this program will be used in another computers. I'll try your suggestion with parameters tomorrow. Thanks
      My Computer


  4. Posts : 17
    Windows 7 Ultimate x64
    Thread Starter
       #4

    Tried to specify full path, still ks1 says that cannot find path and that %date% directory exists, even if it isn't. Added parameter /query to openfiles, no changes. Ks1 works perfectly only when I run it by double-clicking on it. It creates subfolder %date% in folder results and outputs openfiles /query to Active_Files_List.txt

    Tried to edit ks1.bat
    Code:
    @echo off
    REM cd..
    REM cd results
    REM md %date%
    REM cd %date%
    echo Computer detective is running...
    echo.
    echo Copying active files list...
    openfiles /query > Active_Files_List.txt
    echo Task completed. Detective closes...
    ping -n 3 127.0.0.1 >nul
    exit
    When I run it, it creates txt and outputs openfiles, but scheduled from cmd with full path it doesn't.

    This is my schtasks line when i try to schedule from cmd:
    Code:
    schtasks /create /sc minute /mo 1 /tn "Computer Detective" /tr C:\Users\*****\Desktop\OSND\ComputerDetective\tasks\ks1.bat
    Last edited by neone; 23 Oct 2012 at 05:47.
      My Computer


  5. Posts : 17
    Windows 7 Ultimate x64
    Thread Starter
       #5

    Now I noticed that when ks1 says cannot find path specified, it creates %date% folder and txt with openfiles in C:/Windows, but path is correct..
      My Computer


  6. Posts : 6,285
    Windows 10 Pro X64
       #6

    Where is ks1.bat running from?
      My Computer


  7. Posts : 17
    Windows 7 Ultimate x64
    Thread Starter
       #7

    From C:\Users\*****\Desktop\OSND\ComputerDetective\tasks\ks1.bat

    ks1.bat:
    Code:
    @echo off
    cd..
    cd results
    md %date%
    cd %date%
    echo Computer detective is running...
    echo.
    echo Copying active files list...
    openfiles /query > Active_Files_List.txt
    echo Task completed. Computer detective closes...
    ping -n 3 127.0.0.1 >nul
    exit
      My Computer


  8. Posts : 6,285
    Windows 10 Pro X64
       #8

    Is there a results folder under C:\Users\*****\Desktop\OSND\ComputerDetective?

    cd..
    cd results

    expects it to be there.
      My Computer


  9. Posts : 17
    Windows 7 Ultimate x64
    Thread Starter
       #9

    Yes, it is there
      My Computer


  10. Posts : 17
    Windows 7 Ultimate x64
    Thread Starter
       #10

    No ideas, why ks1 cannot find that path cd.. cd results I tried everything
      My Computer


 
Page 1 of 3 123 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:16.
Find Us