Recurring AT scheduling using VBS and batch files.

Heres the text of a post I was involved in over at m.p.scripting.vbscript.

It relates to the process by which you can create a scheduled task that repeats itself more than one time per day on a regular schedule...

ok, now we have three files....

To use this place all three files in the same location.
Call login.vbs in your login script instead of the .bat

make sure you delete this temp file before retrying this procedure...
( or when you have to re-create the task using login.vbs )
c:\>del %temp%\Done.yet


Send your cashier check to : (just kidding)

D.

login.vbs
Const Hide = 0: Dim VBS, ACT, path
Function GetPath()
  path
= WScript.ScriptFullName
  GetPath
= Left(path, InstrRev(path, "\"))
End Function
Set
Act = CreateObject("Wscript.Shell")
VBS
= trim(GetPath) & "\new4.bat """ & trim(GetPath) & "\"" CHECKME"
Act.Run(VBS),Hide,True



normal.vbs
Const Hide = 0: Dim VBS, ACT, path
Function GetPath()
  path
= WScript.ScriptFullName
  GetPath
= Left(path, InstrRev(path, "\"))
End Function
Set
Act = CreateObject("Wscript.Shell")
VBS
= trim(GetPath) & "\new4.bat """ & trim(GetPath) & "\"""
Act.Run(VBS),Hide,True



new4.bat
:: Login Script usage example -- c:\sounds\new4.bat CHECKME > nul
::if we get a %1 (1st passed param == CHECKME)
:: then we know you want to see if we should run
:: this means if the key file exists then just
:: fall out and do nothing
@ECHO off
SET KeyFile=%temp%\Done.yet

if "%2"=="CHECKME" goto CHECKME
GOTO DOIT

:CHECKME
if exist %KeyFile% goto MESSAGE :: we know the intial execution is done.

:DOIT
echo.We Exist!>%KeyFile%
SETLOCAL
SET v_vbs=%temp%\~tmp.VBS
SET v_cmd=%temp%\~tmp.cmd
ECHO Set oFS=CreateObject("Scripting.FileSystemObject")>%v_vbs%
ECHO tim=FormatDateTime(now+1/(1440/1),vbShortTime)>>%v_vbs%
ECHO oFS.CreateTextFile("%v_cmd%",2).Write "set v_input=">>%v_vbs%
ECHO oFS.OpenTextFile("%v_cmd%",8).Write tim>>%v_vbs%
cscript.exe //nologo %v_vbs%
CALL %v_cmd%
DEL %v_vbs%
DEL %v_cmd%
SET v_input
ENDLOCAL & SET v_input=%v_input%

ECHO RUN THE REAL CODE
At %v_input% /interactive "%1normal.vbs" > nul

:MESSAGE
::already initialized the loop code so just fall out




Comments

Popular posts from this blog

Lupeo

Sending CDO Email via VBS with embedded attachments

NLE 2020 NEP