Re: setup a schedule task in WIndows XP

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Pegasus, thank you for your explanation in detail.
The adding of double quotes already solved my problem.
As I am living alone, my PC need no password to log in.
However the windows schedule task needs a log in password to set up the
task.
May this password be skipped?

Kent



"Pegasus [MVP]" <news@xxxxxxxxxxxxx> ¼¶¼g©ó¶l¥ó·s»D:ezgvr90bKHA.4780@xxxxxxxxxxxxxxxxxxxxxxx
There are several issues with the current script:
1. I am still puzzled about the date format discrepancies. I suspect that
you chose a date/time format for your logon account that is different from
the inbuilt default format. While this is OK for Windows, it makes the
batch file unreliable.
2. There is the issue with the leading zeros in the date/time strings
which I mentioned in my previous reply.
3. The issue with folder names having embedded spaces is easily solved by
surrounding the whole name with double quotes.
4. I am concerned about the garbage you get at the end of the log file.
You should see a message such as "1 file copied". Did you perhaps select a
code page that refers to a non-English language?

The modified script below resolves points 1..3 above. I numbered the lines
so that you can undo any line wrapping that your newsreader might cause.
You must then remove the line numbers. Do NOT retype the code - just use
copy & paste!

[01] @echo off
[02] set Scr=c:\TempVBS.vbs
[03] set VB=echo^>^>%Scr%
[04] cd 1>nul 2>%Scr%
[05] %VB% WScript.Echo Year(Date) ^& pad(Month(Date)) ^& pad(Day(Date)) ^&
" " ^& pad(Hour(Now)) ^& pad(Minute(Now))
[06] %VB% Function pad (n)
[07] %VB% pad = Right("0" ^& n, 2)
[08] %VB% End Function
[09] for /F "delims=" %%a in ('cscript //nologo %Scr%') do set
DateStamp=%%a
[10] del %Scr%
[11]
[12] echo Job invoked on %date% at %time:~0,5% 1>> c:\test.txt
[13] echo DateStamp=%DateStamp% 1>> c:\test.txt
[14] copy /y "c:\info.db" "d:\%DateStamp%.db" 1>>c:\test.txt 2>>&1



"Kent" <kft101@xxxxxxxxx> wrote in message
news:u$bfVlybKHA.1648@xxxxxxxxxxxxxxxxxxxxxxx
I also find that the program can copy a file from c:\ to d:\,
but fails to copy from C:\Program Files\info.db to D:\.
When the space between Program & Files is deleted, it works again.
ANy idea please?


"Pegasus [MVP]" <news@xxxxxxxxxxxxx> ¼¶¼g©ó¶l¥ó·s»D:%23CNuc1pbKHA.2188@xxxxxxxxxxxxxxxxxxxxxxx
I detect a contradiction. In your previous reply you wrote this:
- The formats are 2009-11-25 Wednesday, 18:59:01.03
In the current reply it says:
- Job invoked on 26/11/2009 Thu at 17:20

In other words, you said that you had dashes as delimiters in your date
format. The job you ran reports slashes, not dashes. I do not know what
causes the contradiction but you *must* get rid of the slashes. I also
note that the date format is DD/MM/YYYY, not YYYY-MM-DD DDDD as reported
before. This changes things considerably!
@echo off
echo Job invoked on %date% at %time:~0,5% 1>> c:\test.txt
for /F "tokens=1-3" %%a in ('echo %Date:/= %') do set MyDate=%%c%%b%%a
for /F "tokens=1-2" %%a in ('echo %Time::= %') do set MyTime=%%a%%b
echo My Date=%MyDate%, My Time=%MyTime% 1>> c:\test.txt
copy /y c:\info.db "d:\%MyDate% %MyTime%.db" 1>>c:\test.txt 2>>&1


"Kent" <kft101@xxxxxxxxx> wrote in message
news:etfNSqnbKHA.2188@xxxxxxxxxxxxxxxxxxxxxxx
Job invoked on 26/11/2009 Thu at 17:20
My Date=26/11/2009, My Time=1720
¨t²Î§ä¤£¨ì«ü©wªº¸ô®|¡C
½Æ»s¤F 0 ­ÓÀɮסC

From the above test.txt file found the message "invalid path, 0 file
copied"
But I am sure there is a info.db in C:\, and the path D:\ exist.
When I rewrite the last sentence to
copy /y c:\info.db "d:\" 1>>c:\test.txt 2>>&1,
the file info.db can really copied to D:\, but no rename.


Kent




"Pegasus [MVP]" <news@xxxxxxxxxxxxx> ¼¶¼g©ó¶l¥ó·s»D:OMCursfbKHA.5608@xxxxxxxxxxxxxxxxxxxxxxx
Here you go:
@echo off
echo Job invoked on %date% at %time:~0,5% 1>> c:\test.txt
for /F "tokens=1" %%a in ('echo %Date:-=%') do set MyDate=%%a
for /F "tokens=1-2" %%a in ('echo %Time::= %') do set MyTime=%%a%%b
echo My Date=%MyDate%, My Time=%MyTime% 1>> c:\test.txt
copy /y c:\info.db "d:\%MyDate% %MyTime%.db" 1>>c:\test.txt 2>>&1

Instructions:
1. Copy & paste the code into your batch file. Do *not* retype it.
2. Start a Command Prompt.
3. Run the batch file.
4. Examine the log file c:\test.txt. Any error messages?
5. See if the .db file got copied to drive d:.
6. Create a scheduled task to run this batch file.
7. Invoke the scheduled task.
8. Repeat points 4 and 5.
9. If all is well, remove every instance of "1>> c:\test.txt" and
"2>>&1".
Note also:
- If your %date% / %time% variable suppresses leading 0s (e.g.
time=9:59:12 or date=2010-2-9) then your file names will be shortened
accordingly. Adding leading 0s would make the code a little more
complex.
- Having a file name of the form "YYMMDD - HHMM.db" does not guarantee
you a unique name. You can get duplicate names between 1 and 2am on
the day when Daylight Saving Time changes back to Standard Time.
- Ask if you wish to know what's behind the code.


"Kent" <kent@xxxxxxxxxxxx> wrote in message
news:OHkh15bbKHA.1640@xxxxxxxxxxxxxxxxxxxxxxx
I see.
The formats are 2009-11-25 Wednesday, 18:59:01.03



"Pegasus [MVP]" <news@xxxxxxxxxxxxx> ?¤J®ø®§·s?:uvuhCrbbKHA.5576@xxxxxxxxxxxxxxxxxxxxxxx
You must open a Command Prompt:
- Click Start / Run
- Type the three letters cmd
- Click OK
- Type these commands and press the Enter key each time:
echo %date%
echo %time%


"Kent" <kent@xxxxxxxxxxxx> wrote in message
news:uR76HabbKHA.2164@xxxxxxxxxxxxxxxxxxxxxxx
How can I indentify the local format of %date% please?



"Pegasus [MVP]" <news@xxxxxxxxxxxxx> ?¤J®ø®§·s?:%23KTrkIbbKHA.4780@xxxxxxxxxxxxxxxxxxxxxxx
Is it really dd/mm/yyyy? Isn't there a DOW somewhere?

"Kent" <kent@xxxxxxxxxxxx> wrote in message
news:%23B7MokabKHA.5728@xxxxxxxxxxxxxxxxxxxxxxx
the date format is dd/mm/yyyy, time is hh:mm


"Pegasus [MVP]" <news@xxxxxxxxxxxxx> ?¤J®ø®§·s?:%23BowrTabKHA.2184@xxxxxxxxxxxxxxxxxxxxxxx

"Kent" <kft101@xxxxxxxxx> wrote in message
news:OLeTwIYbKHA.1028@xxxxxxxxxxxxxxxxxxxxxxx
Dear all,

I want to write a batch file to set up a scheduled task in
Windows XP:

1. copy a file c:\info.db to d:\ every 10 minutes
2. rename the copied file to a series by adding date time to
prevent duplication, info 091125 0810.db , info 091125 0820.db
etc
3. hidden the dos windows to avoid disturbance during and after
the task execution

Thanks

Kent

Here are some suggestions:
1. Use this command: copy /y c:\info.db d:\
2. The technique depends on your local format for %date%. What
is it?
3. Create a dedicated account called "Scheduler" and use it for
the scheduled task.























.



Relevant Pages

  • Re: setup a schedule task in WIndows XP
    ... I am still puzzled about the date format discrepancies. ... @echo off ... Copy & paste the code into your batch file. ... Create a scheduled task to run this batch file. ...
    (microsoft.public.windowsxp.general)
  • Re: setup a schedule task in WIndows XP
    ... Copy & paste the code into your batch file. ... Create a scheduled task to run this batch file. ... echo %date% ... rename the copied file to a series by adding date time to ...
    (microsoft.public.windowsxp.general)
  • Re: setup a schedule task in WIndows XP
    ... the file names would be more consistent if the time format ... @echo off ... Copy & paste the code into your batch file. ... Create a scheduled task to run this batch file. ...
    (microsoft.public.windowsxp.general)
  • Re: setup a schedule task in WIndows XP
    ... @echo off ... Copy & paste the code into your batch file. ... Create a scheduled task to run this batch file. ... hidden the dos windows to avoid disturbance during and after ...
    (microsoft.public.windowsxp.general)
  • Re: setup a schedule task in WIndows XP
    ... The job you ran reports slashes, not dashes. ... @echo off ... Copy & paste the code into your batch file. ... Create a scheduled task to run this batch file. ...
    (microsoft.public.windowsxp.general)