kingbc
asked on
Batch File to run all vbscripts in a folder
I have an ever growing number of vbscripts that I set up scheduled tasks to run every 15 minutes and there's got to be a better way. Is there a way to put together a batch file that will run every script in a particular folder? That way I could just have one scheduled task to rule them all!
Thanks in advance.
Thanks in advance.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
forfiles /p D:\scripts\ /m *.vbs /c "cmd /c wscript @file"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In regard of "in a particular order", usually you ascertain that by prefixing each file name with e.g. a two-digit number, ascending, and then use the DIR as shown above.
ASKER
Sounds like this should be straight forward yet I'm getting an error.
"windows cannot find "cscript //nologo d:\scripts\file1.vbs...... ."
even though this file and others are in that location.
What am I missing?
"windows cannot find "cscript //nologo d:\scripts\file1.vbs......
even though this file and others are in that location.
What am I missing?
Please post your code. are there spaces in the path or filenames? Have you tried with suitable " " around the paths like in my last example?
Steve
Steve
ASKER
Thanks Steve
Below is the code. The contents of the folder get interated as expected as the error messages shows as much;
-------------------------- ---------- ---
The system cannot find the file cscript //nologo C:\Users\bking\Documents\S cripts\Env Mon\Tasks\ file1.vbs.
The system cannot find the file cscript //nologo C:\Users\bking\Documents\S cripts\Env Mon\Tasks\ file2.vbs.
The system cannot find the file cscript //nologo C:\Users\bking\Documents\S cripts\Env Mon\Tasks\ file3.vbs.
-------------------------- ---------- ----
Exit code: 1 , 0001h
Below is the code. The contents of the folder get interated as expected as the error messages shows as much;
--------------------------
The system cannot find the file cscript //nologo C:\Users\bking\Documents\S
The system cannot find the file cscript //nologo C:\Users\bking\Documents\S
The system cannot find the file cscript //nologo C:\Users\bking\Documents\S
--------------------------
Exit code: 1 , 0001h
@echo off
for %%F in (C:\Users\bking\Documents\Scripts\EnvMon\Tasks\*.vbs) do START "" "cscript //nologo %%F"
on mobile at mo, but try syntax suggested in my last post using di and "" around filename.
Steve
Steve
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Deleting the quotes around the cscript //nologo %%F section did the trick. Problem solved, points to be shared since both dragon-it and qlemo provided essentially the same solution. Thanks to all!
ASKER
Thanks to Steve (dragon-it) for the fast response times on my questions!
No problem, glad it helped.
Steve
Steve