1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

scheduled task doesn't run properly

Discussion in 'Windows XP' started by Ludwig, 2002/08/23.

Thread Status:
Not open for further replies.
  1. 2002/08/23
    Ludwig

    Ludwig Well-Known Member Thread Starter

    Joined:
    2002/01/07
    Messages:
    146
    Likes Received:
    0
    I have a BATCH file which runs successfully on Windows 98 as a scheduled task. Now I have upgraded my machine to XP it doesn't want to behave.

    The scheduled task runs ok (as a task) in the general sense & uses a userid with a set password. The problem comes when it tries to delete a file off a remote computer after copying it locally [.. actually .. after MOVE-ing it locally which should have had the same effect ].

    If the task runs thru the scheduler, it does not delete the file & from what piping of DEL command output I can log, it doesn't complain. Yet the file remains existing on the other machine after DEL has run.

    If I manually run the BATch file from a DOS prompt, the delete happens. Why the difference?

    In case you are wondering why I would do this, I fetch my NAV signature updates from a preset location on my other PC directly connected to the Internet. So I only need download them once & my other 3(!) machines check regularly for updated signatures using a BAT file run by Task Scheduler.
    i.e. I've created my own version of "LiveUpdate ".

    Any ideas what's going on, and how I can get DEL to work? The userid has the necessary rights on the other computer to do it.
     
  2. 2002/08/23
    Newt

    Newt Inactive

    Joined:
    2002/01/07
    Messages:
    10,974
    Likes Received:
    2
    Post the bat file. May be something someone here can spot right away or if not, can experiment with.
     
    Newt,
    #2

  3. to hide this advert.

  4. 2002/08/26
    Ludwig

    Ludwig Well-Known Member Thread Starter

    Joined:
    2002/01/07
    Messages:
    146
    Likes Received:
    0
    The BATch file with some tracing lines in it follows below. Note that it runs fine on two Windows 98SE machine, plus on Windows XP when the scheduled task is manually RUN from the schedule menu. Just doesn't want to delete the file (at MOVE or explicit DELETE statements).


    ==== Start of BATCH file ====

    @echo off

    REM Run the current NAV Signature file.

    if [%NAV_fn%] == [] set NAV_fn=NAV_Sigs.exe
    set NAVlogfn=NAV_updates.log

    REM First check if there is a new one to pick up .. deposited on P1000 when I was offline
    if [%COMPUTERNAME%] == [P1000] goto End_Pickup
    if [%COMPUTERNAME%] == [] call Get_Name.BAT

    REM *** START Temporary trace code ***
    echo. >> %NAVlogfn%
    echo ********* starting *********** >> %NAVlogfn%
    echo .. starting to check for latest updates for %COMPUTERNAME%. >> %NAVlogfn%
    echo. | date | find /i "current" > %temp%\temp.txt
    echo. | time | find /i "current" >> %temp%\temp.txt
    type %temp%\temp.txt >> %NAVlogfn%
    REM *** START temporary trace code ***

    if not exist \\P1000\NAV_Sigs\Pick_Ups\%COMPUTERNAME%\%NAV_fn% echo nothing to pick up. >> %NAVlogfn%
    if not exist \\P1000\NAV_Sigs\Pick_Ups\%COMPUTERNAME%\%NAV_fn% goto End_Pickup
    echo Picking up file from P1000 >> %NAVlogfn%
    REM this next line should "copy" then "delete" the files ..
    REM but it doesnt want to .. weird.
    MOVE /Y \\P1000\NAV_Sigs\Pick_Ups\%COMPUTERNAME%\*.* .\
    if errorlevel 1 goto Msg1
    dir .\*.EXE >> %NAVlogfn%
    goto Chk_Pickup
    :Msg1
    echo. >> %NAVlogfn%
    echo .. ERROR attempting to pick up latest updates for %COMPUTERNAME%. >> %NAVlogfn%
    echo .. ERROR attempting to pick up latest updates for %COMPUTERNAME%.

    :Chk_Pickup
    REM For Windows HELP.net ..
    REM This section of inserted code here tells me "still exists! "
    dir \\P1000\NAV_Sigs\Pick_Ups\%COMPUTERNAME%\*.* /-P
    dir \\P1000\NAV_Sigs\Pick_Ups\%COMPUTERNAME%\*.* /-P >> %NAVlogfn%
    if not exist \\P1000\NAV_Sigs\Pick_Ups\%COMPUTERNAME%\%NAV_fn% goto End_Pickup
    echo Picked up file still exists!! Will delete .. >> %NAVlogfn%
    DEL \\P1000\NAV_Sigs\Pick_Ups\%COMPUTERNAME%\%NAV_fn% >> %NAVlogfn%
    if exist \\P1000\NAV_Sigs\Pick_Ups\%COMPUTERNAME%\%NAV_fn% echo ?? still exists!! >> %NAVlogfn%

    :End_Pickup


    if not exist %NAV_fn% echo nothing to apply this time
    if not exist %NAV_fn% echo nothing to apply this time >> %NAVlogfn%
    if not exist %NAV_fn% goto :LFini

    REM Use START command to pause this batch file while it runs.
    REM Use the Q for QUIET switch so no prompts appear .. just apply them

    echo. >> %NAVlogfn%
    echo applying latest signatures to %COMPUTERNAME% .. >> %NAVlogfn%
    echo. | date | find /i "current" > %temp%\temp.txt
    echo. | time | find /i "current" >> %temp%\temp.txt
    type %temp%\temp.txt >> %NAVlogfn%
    dir .\*.EXE >> %NAVlogfn%
    start /w %NAV_fn% /Q

    if errorlevel 1 goto Err
    echo %0 - latest signatures now applied to %COMPUTERNAME%.
    echo Update applied successfully to %COMPUTERNAME%. >> %NAVlogfn%
    DEL %NAV_fn% >> %NAVlogfn%
    goto Log_end
    :Err
    echo %0 -
    echo Error applying latest NAV updates to %COMPUTERNAME%. Please check why and rerun.
    echo Update to %COMPUTERNAME% failed. >> %NAVlogfn%

    :Log_end
    echo. | date | find /i "current" > %temp%\temp.txt
    echo. | time | find /i "current" >> %temp%\temp.txt
    type %temp%\temp.txt >> %NAVlogfn%
    echo. >> %NAVlogfn%

    :LFini
    echo ********* ended *********** >> %NAVlogfn%
    set NAVlogfn=
     
  5. 2002/08/26
    Newt

    Newt Inactive

    Joined:
    2002/01/07
    Messages:
    10,974
    Likes Received:
    2
    Interesting. And certainly looks like it should work unless there is a permissions issue - and you say not.

    For troubleshooting, how about changing from the single MOVE command to an explicit copy line and a second delete line. That should give more of an idea where the problem comes from.

    I've run into several occasions when I could do a procedure manually but it failed thru scheduler. And every time I've located the problem, I've felt sorta silly that it took so long to spot it.

    You didn't mention if you are on a domain or not but one things that occurs to me is the runas line built by the scheduler wizard may have mis-identified the user and used something like

    computername\username

    rather than

    domain\username

    and in that case, if the share/folder permissions was open for all to copy from but restricted in who could modify/delete, you would see similar behavior.
     
    Newt,
    #4
  6. 2002/08/28
    Ludwig

    Ludwig Well-Known Member Thread Starter

    Joined:
    2002/01/07
    Messages:
    146
    Likes Received:
    0
    I'll make some tweaks and run some more tests

    Thanks for the suggestion. I'll try replacing MOVE with XCOPY and a separate DEL. Mind you, the separate DEL attempted further down doesn't work. I'll try anything anything to see if I can fool it into working though.

    The userid & password used when run manually (from a scheduler entry right-click & choose "run ") should I assume be the same as when it is run by the scheduler automatically.

    My home setup is only a workgroup and connections with common userid defined on each machine, with same password, seems to connect happily for other tasks (e.g. permanent explorer maps to areas on the Windows 2000 machine) - from both Win98SE and WinXP.
    That's the strange thing, interactively I can delet a file quite happily(!), and when manually RUN as a scheduled task .. just not when the timer evenmt is triggered ... "growl mutter mutter frustration ".
     
  7. 2002/08/30
    Ludwig

    Ludwig Well-Known Member Thread Starter

    Joined:
    2002/01/07
    Messages:
    146
    Likes Received:
    0
    Well, modifying the BATch file [to XCOPY then DEL] didn't make a difference.

    So I went back to basics so to speak .. I set up the area on the other machine from scratch and it all works fine :confused:

    Compared the security settings and no differences, even in advanced, that I could see. I guess something was though.

    At least now I'm a happy camper once more :p. Thanks for your help Newt
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.