Link to home
Start Free TrialLog in
Avatar of ksuchy
ksuchyFlag for United States of America

asked on

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

SOLUTION
Avatar of BobTheViolent
BobTheViolent
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ksuchy

ASKER

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

Avatar of ksuchy

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of ltlbearand3
ltlbearand3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ksuchy

ASKER

Thanks :-)