I am writing an HTML Menu (StartMenu.hta). This menu runs from a DVD, but before it can run it needs to copy a few files to the user’s TEMP folder. These files have to be copied before the menu is opened, because these files are necessary for the use of the menu.
To copy these files, I use the following JavaScript function:
function launch(){
var shell = new ActiveXObject("WScript.Shell");
shell.run("xcopy \Data\\VLC\ \%TEMP%\\CSE\\VLC\ /d/e/i/y");
shell.run("xcopy \Data\\VIEWER\ \%TEMP%\\CSE\\VIEWER\ /d/e/i/y");
shell.run("StartMenuPC.hta");
}
The problem I have is that the copying and the opening of the menu start simultaneously, instead of the last command waiting for the previous two to finish.
I have considered using batch files instead, but that might encounter a conflict with some firewalls.
I have also tried using while loops and even checking to see if the files exist in their new location, but as I don’t know a lot about HTML. I also don’t want to use a timeout because the disc will only need to copy the files once.
shell.runtakes a third parameter which defines if the action should be completed before moving forward or not. So the code should be smth likeSee MSDN Windows Script Host Run Method for a complete explanation