Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Couple of script problems 1

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
US
I have a script which basically does the following:

1. Opens a file and reads from it and closes it
2. Runs a select query on a database
3. Starts a loop and runs a .BAT file in a shell window
4. writes to a file
5. Sleeps for 5 mins and does it all again.

I have a couple of problems with this. The first is that while looping the batch files are getting caught up with themselves and not running properly as a result. I need a way of setting it up so that a batch file doesn't run until the previous one is finished. I tried using Wsshell.Exec method and sleeping while the status was zero but it tells me that Exec is not a valid method. I am using Run at the moment and then sleeping but the sleep time is not enough if the PC is under heavy load and too much if the PC is idle. So I need a way to only start a batch file once the previous execution is complete.

Secondly, I need to set this script up to run once the PC has started - regardless of who is logged in. How do I do this and how do I ensure that the PC will have permission to read/write the file and read from the database.

Thanks in advance for any advice.

Can post code if required.

Mighty
 
Hey mighty:

you might have already thought of these but just in case, here are a few ideas that may help:

you could remove the .bat file and run similar code in your .vbs, this would probably be more precise

if you are already using the run method, you could set the wait on return value to true, this way the it the sleep portion of the script wont even start until the .bat file returns in the first place

as far as starting up on log in, you could drop a shortcut in the start up file in the all users profile. You would have to check the privileges of the files you are working with, might even look in to encrypting your vbscript

hth,
sg284

 
Thanks for the suggestions. Will test them out.

Mighty
 
np let me know if you need examples or additional help

sg284
 
Seems to be working fine. Just added a shortcut to the script file in the all users startup folder and altered the run command so that it would wait for the previous shell command to finish.

Working OK ...... I think

Mighty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top