extreme
I have a batch file doing this:

echo blabla > file.vbs
echo some_more_stuff > file.vbs

so, after the file is created, I wish to execute it using:

cscript.exe file.vbs

but it won't work, since the script doesn't create file before I run this command, so I have to make something like this:

echo blabla > file.vbs
echo some_more_stuff > file.vbs
sleep(2000);
cscript.exe file.vbs

...or even better(this is more secure and more professionall then using sleep() ), if possible:

echo blabla > file.vbs
echo some_more_stuff > file.vbs
:WORK
If FileExists("file.vbs")
cscript.exe file.vbs
else GOTO WORK
kbnet
Not sure what you can do with the sleep unless you download the sleep command. http://malektips.com/xp_dos_0002.html

Just whipped this up. It will test if a file exists...

CODE

@echo off
echo Testing for file existence.
IF EXIST afile.dat echo This file exists
echo Quitting



You may want to consider revising a section of your code, because it could force your BAT file to crash. Possibility of a infinite loop.

CODE

:WORK
If FileExists("file.vbs")
cscript.exe file.vbs
else GOTO WORK
extreme
THx..
But why would it be infinite loop? VBS file will be created sooner or later, and if that doesn't happen for who knows what reason, let it loop to infinity..
kbnet
You always want to take every precaution to prevent software from crashing. GOTO statements are considered dangerous, if the file never does not exist (for whatever reason) then looping it to infinity is not a good idea, you would want to have in a 'safety net' to prevent the BAT file from hanging.

In this circumstance im being very picky over a BAT file, its not exactly necessary to perform sanity checking for what your doing. Ive just been doing alot of formal software development lately so every piece of code i c im always thinking about checks, validation, reliability etc.. its just something to bare in mind.
Anarchiste
If you want to sleep before call interpreter then use ping and ping localhost (look at ping options, try with some differents) ...it is very usefull wink.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.

 
Invision Power Board © 2001-2005 Invision Power Services, Inc.