Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

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?

Posted

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.

Posted

I have no idea what you mean... :confused:

 

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

Posted
I have no idea what you mean... :confused:

 

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 -

 

@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"

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...