+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, .bat script in Coding and Web Development; Hi, just looking for nsome help, I am writing a small backup script. I have the code to copy the ...
  1. #1
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    220
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    10

    .bat script

    Hi, just looking for nsome help, I am writing a small backup script. I have the code to copy the source to the destination and it works well. I was just wondering if after my copy command had run there is any way to send a notification box?
    I have the box written in .vbs and have tried to call it in the bat file but it comes as the script starts...

    I guess what I'm asking is,

    Is there any way to get a process to wait for a previous process to finish in a bat file?

  2. IDG Tech News

  3. #2

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    8,472
    Thank Post
    889
    Thanked 890 Times in 532 Posts
    Rep Power
    596
    Stick in a conditional statement or a flag file to look for and loop it........

    Use 'for' if using batch.

    http://www.robvanderwoude.com/for.php
    Last edited by mattx; 23rd November 2009 at 01:20 PM.

  4. #3

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    60
    If you put a call to cscript/wscript to run the VBS after the line with the copy command it shouldn't execute till the copy command is finished. The bat file should run line by line, the previous line isn't usually considered finished until the program it has launched has exited - the exception being if you use a 'start' at the start of the line to launch a program without waiting... You don't have the vbs before the copy do you?

    If you want the bat to exit after the copy is done and launch a notification without getting stuck in the background you'd want a 'start' at the start of the wscript line.

  5. #4
    neon's Avatar
    Join Date
    Apr 2009
    Location
    Market Harborough
    Posts
    220
    Thank Post
    7
    Thanked 22 Times in 20 Posts
    Rep Power
    10
    I have no idea what you mean...

    could you write me an example please?

    heres the code:

    eventcreate /t information /id 998 /l application /d "Update.bat has started"
    start /wait /b xcopy "C:\Documents and Settings\administrator\My Documents\*.*" "C:\Documents and Settings\administrator\Desktop\backup" /c /d /s /e /k /y /z /i
    eventcreate /t information /id 998 /l application /d "Update.bat has finished"
    call "C:\Documents and Settings\administrator\Desktop\success.vbs"

    Thank you

  6. #5
    Marci's Avatar
    Join Date
    Jun 2008
    Location
    Wakefield, West Yorkshire
    Posts
    565
    Thank Post
    39
    Thanked 123 Times in 100 Posts
    Rep Power
    32
    Remove start /wait /b from the xcopy line...

  7. #6

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    60
    Quote Originally Posted by neon View Post
    I have no idea what you mean...

    could you write me an example please?

    heres the code:

    eventcreate /t information /id 998 /l application /d "Update.bat has started"
    start /wait /b xcopy "C:\Documents and Settings\administrator\My Documents\*.*" "C:\Documents and Settings\administrator\Desktop\backup" /c /d /s /e /k /y /z /i
    eventcreate /t information /id 998 /l application /d "Update.bat has finished"
    call "C:\Documents and Settings\administrator\Desktop\success.vbs"

    Thank you
    Think you have it already basically except where you've used start /wait /b I would do it directly within the batch file and log the output so you can check for errors later. It's probably this that's throwing the VBS up early?

    My tweaked version of your script -

    Code:
    @echo off
    eventcreate /t information /id 998 /l application /d "Update.bat has started"
    REM removed start /wait /b from the line below, added a redirect for output to a log file with todays date
    xcopy "C:\Documents and Settings\administrator\My Documents\*.*" "C:\Documents and Settings\administrator\Desktop\backup" /c /d /s /e /k /y /z /i > "C:\Documents and Settings\administrator\Desktop\backup\%date:~6,4%-%date:~3,2%-%date:~0,2%.log"
    eventcreate /t information /id 998 /l application /d "Update.bat has finished"
    REM added start wscript to the line below to allow the bat to exit whilst the message box is still open 
    start wscript "C:\Documents and Settings\administrator\Desktop\success.vbs"

SHARE:
+ Post New Thread

Similar Threads

  1. Rar archive with date backup script (.bat)
    By RabbieBurns in forum Scripts
    Replies: 1
    Last Post: 20th November 2009, 03:05 AM
  2. The Bat
    By Dos_Box in forum General Chat
    Replies: 1
    Last Post: 11th July 2008, 01:19 PM
  3. SIMSPERM.bat
    By cookie_monster in forum MIS Systems
    Replies: 10
    Last Post: 11th February 2008, 01:28 PM
  4. simsperm.bat
    By robert.mabbutt in forum MIS Systems
    Replies: 9
    Last Post: 15th August 2007, 09:43 PM
  5. Deploy software (K-Lite) via a .bat script
    By OverWorked in forum How do you do....it?
    Replies: 2
    Last Post: 21st September 2006, 12:59 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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