need simple standalone batch script to create cmd shell, run exe, sleep 6 seconds

Hi SysAdmins & VBScript Folks,

Thank you for a moment of your time.

I'm running a program called SyncBackSE, which runs some very cool FTP stuff as a background task every 6 seconds while I'm logged on.

The problem is that when I log off, the background task will no longer run, and the smallest possible increment for scheduling tasks in Windows Task Manager is one minute.

I need a very simple standalone VBScript (not embedded in an asp or other page), which will run on a server I have.

Ultimately, I need to run this line:
"C:\Program Files\2BrightSparks\SyncBackSE\SyncBackSE.exe" -m "funny name goes here"

I need to run the above line every 6 seconds, for 24 hrs a day, 7 days a week, 365 days a year.

The solution I've devised is to create a Windows task scheduler task that kicks off a vbscript every 1 minute, repeatedly, indefinitely, daily.

It will kick off the vbscript, and the vbscript will execute the line I've pasted above, with the .exe in it.
This vbscript should run this line once, then sleep for 6 seconds, and then do it again for 10 loops (probably do while) ..... in other words, 10 times per minute, or once every 6 seconds.

This way, if the script gets hung for any reason, it will be restarted again once every minute, when the task manager kicks it off.  (I'm wondering if this is the most reliable way to keep this going without hickups or hangs).

Obviously, I want this to run all the time, not just when I'm logged on as Admin.

Don't forget to escape any characters (quotes?) that may need it in the execution of the binary file (you can probably substitute notepad.exe or some other binary since you may not want to download and test with SyncBackSE).

PLEASE provide me a very simple vbscript that WORKS, for 500 easy pts.  

Thanks so much!,
~k


create command shell and supress debugging/errors/popups
 
i=1
Do While i < 11
     "C:\Program Files\2BrightSparks\SyncBackSE\SyncBackSE.exe" -m "funny name goes here"
     WScript.Sleep 6
      i = i + 1
Loop
clean up and exit

Open in new window

ksuchyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BobTheViolentCommented:
Pretty easy,

Try this one.  Our server runs something like this during times of the day.

The sleep value is in milliseconds.  1000 = 1 second

Is that what you needed?

THIS GOES IN A .VBS FILE NAMED LOOP.VBS FOR EXAMPLE
 
set wsobject = wscript.createobject("wscript.shell")
 
do while 1=1
  wsobject.run "somefilename.exe",0,TRUE
  wscript.sleep 6000
loop
 
 
THIS GOES IN A .BAT FILE IN THE SAME DIRECTORY
cscript loop.vbs %1

Open in new window

ksuchyAuthor Commented:
Hi Bob,

Thank you for your help.  

What you have included here is a good start, but incomplete and it does not do everything I've asked.  I'm asking for one simple (aka, "easy") script, which does everything I've asked, and has already been debugged and tested to work, and accomplishes everything I've asked, including escaping quotes in the path+switches.  Please if possible, carefully review my original post which includes full details and requirements.

Kind Regards,
~k

ksuchyAuthor Commented:
The below code actually works, but only once.
When I have it scheduled to repeat every 1 minute (duration set to 2 minutes, because MS apparently requires duration to be longer than repetition interval), then it kicks off and goes through the loop 10 times, but then that's it.

Not sure why.
Any ideas?
set wsobject = wscript.createobject("wscript.shell")
i=1
do while i<11
  strEXE = """C:\Program Files\2BrightSparks\SyncBackSE\SyncBackSE.exe"" -m ""FTPWebcam"""
  wsobject.run strEXE,0,TRUE
  wscript.sleep 6000
  i=i+1
loop

Open in new window

Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

ltlbearand3Commented:
vbScript keeps going through the code while your wsobject.run line is running.  To make it wait for the completion of the .run command you need to assign it to a variable.

Try the following

set wsobject = wscript.createobject("wscript.shell")
i=1
do while i<11
  strEXE = """C:\Program Files\2BrightSparks\SyncBackSE\SyncBackSE.exe"" -m ""FTPWebcam"""
  strReturn = wsobject.run(strEXE,0,TRUE)
  wscript.sleep 6000
  i=i+1
loop

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChizlCommented:
You can also use:

Set process = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2:Win32_process")
strUpdateCommand = "myexe.exe parm1 parm2"
result = process.create(strCommand,Null,Null,processid)
If result <> 0 Then
    MsgBox "Failed to process"
End If
ksuchyAuthor Commented:
Thanks :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.