Scheduling a task using VBScript at specific mentioned time.

Hello,
I have a script which needs to be updated/debugged to start my task at the specific date and time (Currently, this script executes if the scheduling is done for that day, i wanted to delay the task to start by next day it doesn't work,something is wrong,
as its not launching at the particular time instead some other time is considered for launching the task).
Below is the Function:
Function TaskScript
    Dim scheduledTime, waited
    Dim objShell
    Set objShell = Wscript.CreateObject("WScript.Shell")
    Dim shour, sminute
    shour = Inputbox("Enter hour : (in 24h format)." & vbCrLf & "For example: 3 PM should be 15")
    sminute = Inputbox("Enter Minute for scheduling")
    Do
      scheduledTime = Int(Now) + TimeSerial(shour, sminute, 00)
      waited = DateDiff("S", Now, scheduledTime)
      msgbox "Task Activated"
      If waited <= 600 Then
         Wscript.Sleep waited * 1000
         objShell.run Launch_DB
         Wscript.Quit
      Else
         WScript.Sleep 590 * 1000
      End If
    Loop
End Function
For Example : If i call the above function and mention shour = 13 and sminute = 00. the script exactly launches at 13h00.
Question :
If i wanted to execute my task next day, What should be the shour and sminute value? (I tried giving it like adding 24 (to say not today) + 13 (the next day) = 37 as shour, it doesn't invoke at next day 13h00, instead its delayed)
Any help would be really appreciated.
Thanks in Advance.
sbk

Organizational or dis-organizational. You can wait on a time like this.
''Get todays adjusted start Time
dDateTIme = CDate(CStr(Date) & " 13:00")
'' add 1 to get tomorrows date
dLaunchTime=DateAdd("d",1, dDateTime)
'' wait in loop until time arrives.
While Now < dLaunchTime
WScript.Sleep 60 * 1000
Wend
'' run your program and quit.
Wscript.CreateObject("WScript.Shell").Run "notepad.exe"
Simple, uncomplicated and never fails although I wouldn't rely on simple VBScript for anything complicated.  It will create the illusion to your boss that you are hard at work after lunch the next day.  Better hope he doesn't have a camera focused
on you.
¯\_(ツ)_/¯

Similar Messages

  • Schedule a task for a given period of time

    Hi,
    any body has an idea how to schedule a task for a specified period of time. e.g A program keeps on asking for your name to be input for an hour and then start doing something else?
    /bob

    hi friend,
    Why don't you try using a TIMER. Try using this code
    Timer timer = new Timer((TIMER), new ActionListener()
         public void actionPerformed(ActionEvent ae)
    // perform your task here...
    timer.setInitialDelay(TIMER);
    timer.setRepeats(true);
    timer.start();
    I think this will work fine.
    Bye,
    Ravi.

  • Server 2008 R2: Setting up a custom schedule with task scheduler

    I am trying to schedule a task using Server 2008 R2 Task Scheduler
    I've been googling and searching for an answer on how to do this. I could easily do it on Server 2003.
    I need to run a program (custom) that updates some tables in a database.
    I need to run it Monday thru Saturday at 20 minutes after the hour from 7:20 am through 5:20pm. Not on Sunday and not at night (only normal business hours)
    These are the steps I am following: I create task, General, I enter the description, Then triggers, new, select weekly, select start date and time, select the days I want (every day except sunday), repeat the task every hour, for a duration of (all I can
    choose is 12 hours).. This is where I am stuck. I guess I could choose 12 hours but I need it to stop at 5:20 pm not 7:20pm. Has anybody done something similar to this?

    Go ahead and choose something appropriate in dropdowns on Edit Trigger then over-type them with whatever you want.
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • Creating a Scheduled Task using PowerShell v4

    So here is my question.  I'm trying/wanting to create a scheduled task using PowerShell v4 on Server 2012R2.  I want to task to run on the 1st day of every month.  The parameter for -Monthly -Day is not available.  I need to use PowerShell
    to create the Scheduled Task because the Task will be running with a group Managed Service Account credentials so the Scheduled Task can not be created via the Task Scheduler GUI.
    Thanks in Advance

    Here is a functioning task It can be easily edited in PowerShell or in notepad to alter the timing
    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.1" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
    <RegistrationInfo>
    <Author>W8TEST\user01</Author>
    </RegistrationInfo>
    <Triggers>
    <CalendarTrigger>
    <StartBoundary>2014-06-04T21:31:32.0459499</StartBoundary>
    <Enabled>true</Enabled>
    <ScheduleByMonth>
    <DaysOfMonth>
    <Day>1</Day>
    <Day>12</Day>
    <Day>24</Day>
    </DaysOfMonth>
    <Months>
    <January />
    <February />
    <March />
    <April />
    <May />
    <June />
    <July />
    <August /
    <September />
    <October />
    <November />
    <December />
    </Months>
    </ScheduleByMonth>
    </CalendarTrigger>
    </Triggers>
    <Principals>
    <Principal id="Author">
    <RunLevel>LeastPrivilege</RunLevel>
    <UserId>W8TEST\jvierra</UserId>
    <LogonType>InteractiveToken</LogonType>
    </Principal>
    </Principals>
    <Settings>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <IdleSettings>
    <StopOnIdleEnd>true</StopOnIdleEnd>
    <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
    </Settings>
    <Actions Context="Author">
    <Exec>
    <Command>notepad.exe</Command>
    <Arguments>test.txt</Arguments>
    <WorkingDirectory>c:\temp</WorkingDirectory>
    </Exec>
    </Actions>
    </Task>
    I have edited and reloaded the XML many, many times.  It works very nicely.
    ¯\_(ツ)_/¯

  • How do I schedule a task at a specific time of day, every day?

    I am trying to use Timer and TimerTask to schedule an event at specific time of the day. It will basically stop all the logging archive the log file and start a new logfile.
    I am just having trouble with scheduling it for every day at specific time (I am new to java and have not worked with date and time much). If someone can point me to some sample code or show me a brief example I would really appreciate it. I am about to pull my hair.
    Thanks in advance!!!

    hi
    I assume you use the swing class. As you suggest, to schedule an event you have to use a timer. The delay of the timer can easy be calculated using GregorianCalendar objects. Create one for the current date/time by instantiating an object. Create a second and set the date to the next schedule date/time. Retrieve the milliseconds from both objects and calculate the differences.
    best regards
    benny

  • Creating Windows Basic Task using powershell

    Hello Everyone,
    Please help me out in the below situation:
    I have to create a basic windows task using powershell to run a script on a specific date and time.
    Let me make it even clear :
    I have a csv say,
    D:\xyz.csv
    ServerName ,  Date  , Time
    Random1,   11/15/2014,01:00:00PM
    Random2,   12/01/2015,03:00:00PM
    ...and so on
    I also have a script at E:\TestingServer.ps1
    I need to create list of windows tasks to invoke TestingServer.ps1 with parameters as servername and Time of task as given date and time in csv.
    Task1- with input as ServerName at Date and time from CSV
    Task2-with input as ServerName at Date and time from CSV

    Well here is a good article showing howto do this:
    http://blogs.technet.com/b/heyscriptingguy/archive/2012/09/18/create-a-powershell-scheduled-job.aspx
    ¯\_(ツ)_/¯

  • How do I get the number of channels available in DIAdem using VBScript?

    I want to know the last number of the available channels in DIAdem-DATA using VBScript. If there are not enough channels, I'll allocate new ones using ChnAlloc.
    For the first run of the script, I do know there're 60 channels, but in a second run I might have created the additional channels already (if the script didn't fail) and I don't want to do the allocation a second time. So I need to know the number of the last channel. Unfortunatly I didn't find any function in the help providing this number.
    Thanks,
    Carsten

    Hi Carsten,
    I have a few thoughts for you plus some useful code. Bear in mind that you can change the number of static DIAdem channels (by default 60 of length 8192) as well as the number of available dynamic channels (by default 1000) to whatever you want. These memory matrix settings get stored in your Desktop.DDD file (DIAdem's ini file), so that each time you launch DIAdem it will create the channels according to your specifications. The maximum number of channels of all types that DIAdem can have is 65536 (2^16).
    Secondly, don't forget that you can address channels by name or by number. If the channels are named distinctly, addressing channels by name is the most reliable method. If you use ChnAlloc() to allocate new channels, and you want to address those new channels by channel number, you MUST use CNo() immediately after creating the new channel in order to find out that channel's number. It will not always be the next available channel number, because the next available channel may not be long enough. ChnAlloc() will latch on to an existing channel if it can find one long enough, and it will create new channels only if it finds none of the existing channels suitable.
    In the VBScript I attached to this email you will find all the DIAdem variables which contain information about the maximum available channels and the maximum length of each channel (not its currently set length). Note that DIAdem's data matrix is divided into 8 submatrices, each with 2 GBytes of addressable memory (2^31 Bytes). Each submatrix can have multiple static channels assigned to it. DIAdem's dynamic channels come first from DIAdem's application RAM (Windows allocates no more than 2 GBytes per application) then from the Windows swap file for its virtual memory
    Now, in addition to the variables which tell you the maximum possible channel count and lengths, another very useful variable is "GlobUsedChn", which returns the highest channel number currently filled with some amount of data.
    Ask if you have additional questions,
    Brad Turpin
    NI
    Attachments:
    View_DataMatrix.VBS ‏2 KB

  • How can I script Adobe Reader updates using vbScript, PowerShell or C#?

    I would like to script Adobe Reader updates using vbScript, PowerShell or C#, are there any Adobe API calls I use to do this.  There are several different version that I support and auto update is not an option. I do updates at a specific time of the month. I would like to write a script that would download and install the update for the currently installed version of Adobe Reader (32 or 64 bit) for the version of the OS (32 or 64bit). I can detect the OS version and the Adobe version.  I can download updates but I do not want to hard code anything

    Sabian is correct.
    Most admins download the updates from the ftp site and push via AIP, GPO, SCCM, or some other method whenever it makes sense for them.
    Ben

  • Can u schedule emails to go out at specific times?  if yes, how?

    can u schedule emails to go out at specific times? if yes, how?

    Not in Mail. You might be able to create Applescripts that would do that. There also might be a third-party solution (that probably uses applescript) to do what you want. Check the [MacUpdate|http://www.macupdate.com> site or [Hawk Wings|http://www.hawkwings.net>.

  • Is it possible to create a list of NI-DAQmx tasks used in a VI in LV7.1?

    Hello,
    I was wondering if there is a built in function for Labview 7.1 that would allow me to generate a list of DAQmx tasks or global channels that are being used in the VI.
    Thanks,
    Steve

    Welcome to the Discussion Forums,
    Steve!
    Since I’m a visual person, I wanted
    to make it clear where these properties are found by posting a picture.
    I also wanted to clarify and say
    that these properties show the global channels and tasks saved on your system.
    They do not indicate which are used by a specific VI. This is because global
    channels are not bound to any particular VI. Any indicator you could include in
    your VI would just return the names that are being assigned as inputs. So the
    best way to know what’s being used in your VI is to look at what the inputs
    are.
    I hope this helps. If this isn’t
    exactly what you’re looking for, will you please post again and clarify your
    application?
    Message Edited by Mark E on 11-07-2007 09:29 AM
    Mark E.
    Precision DC Product Support Engineer
    National Instruments
    Digital Multimeters (DMMs) and LCR Meters
    Programmable Power Supplies and Source Measure Units
    Attachments:
    System_node2.JPG ‏106 KB

  • Scheduling a task 1 year (365 days) out

    I am trying to schedule a task for 365 days out (1 year/52 weeks) and am encountering errors with the automatic scheduling. Work will be performed on the weekends, year-round, from 8:00 AM to 5:00 PM. I have set the "Change Working Time" options
    to consider the weekends working days, as well as set up my Scheduling default Options to: "Sunday week start"; "8 hour days"; "56 hours per week"; and "30 days per month".  However, when I enter 365 days under
    duration, the automatic scheduling is completely off.  Very frustrating... Please help!!

    Hi,
    I just ran a test and the task was scheduled accordingly
    What I have done was to set the Saturday and Sunday as working days in Change Working time
    if you are using 'days' to schedule your tasks, there is no need to change the other options (e.g. Hours per week)
    If you are assigning resources to your task, make sure the resource calendar is also having Saturday and Sunday as working days
    Hope this helps
    Paul

  • Scheduled Planner tasks and control validity

    Use case is outlined below:
    Local Control A is valid from 1/1/14 to 12/31/14. I'm trying to schedule a planner task with activity 'Test Control Effectiveness' for this local control. The task being scheduled is a recurring task starting from 1/1/15 to 1/1/17. As can be seen the planner task start date is post the 'Valid To' date of the control. So, essentially the control is not active during the duration for which the planner task is scheduled for. The system did not show an error message. Is this expected behavior? Also, even after I delete the scheduled planner task, I can no longer revise the 'Valid To' of the local control.
    I'd appreciate any document that outlines the pre-requisites for selecting object(s) within different planner tasks.
    Appreciate any help I can get with this!
    Thanks,
    Anju.

    I don't know what Control-M is, but if it can invoke a java task, then it can connect to OIM and start the scheduled task.
    A scheduled task doesn't have to be run within OIM. The scheduler within OIM simply provides a way to invoke the java code that performs tasks or Recons within OIM. So long as your system can run java to connect to OIM and run some code, you can run it in whatever way you'd like.
    -Kevin

  • Is there any utility in LabVIEW or LabVIEW add-on that does scheduling of tasks?

    I am trying to use LabVIEW to automate a process using various instruments. I need some utility that does the scheduling of tasks for me.

    Hi VipersView,
    What you are looking for is TestStand, which is the successor to the LabView TestExecutive toolkit. It is much easier to use and yet much more robust at the same time. You can create your test steps in virtually any language, including LabView G, C, C++, VB, Delphi, and so on. It also provides the ability to run tests on UUTs in parallel and as batches, while at the same time synchronizing the use of shared resources. TestStand is excellent for modularizing your automated test process and creating full test procedures that are adaptive and reusable.
    Here is the product page for TestStand, I highly recommend downloading the demo and looking at the tutorials and manuals for more info.:
    http://www.ni.com/teststand
    Jason F.
    Application
    s Engineer
    National Instruments
    www.ni.com/ask

  • How can I script Firefox updates using vbScript, PowerShell or C#?

    I would like to script Firefox updates using vbScript, PowerShell or C#, are there any API calls I use to do this? There are several different OS version versions that I support and auto update is not an option. I do updates at a specific time of the month. I would like to write a script that would download and install the update for the currently installed version of Firefox (32 or 64 bit) for the version of the OS (32 or 64bit). I can detect the OS version and the Firefox version. I can download updates but I do not want to hard code anything.

    hello, for some documentation on how the firefox updates work, please refer to https://wiki.mozilla.org/Software_Update (also the links at the bottom of the page!).

  • Facility of Scheduling background tasks  in jdk1.2.2 as avb in jdk1.3

    JDK1.3 - java.util.Timer
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be scheduled for one-time execution, or for repeated execution at regular intervals.
    I want to know what is alternate to this in jdk1.2.2.
    I want to schedule teh tasks for thread to run in background in future using jdk1.2.2.

    Hello all,
    Is there a timer class that I can use for a stopwatch program for PersonalJava, which uses jdk 1.2.2? The java.util.Timer class is available starting with jdk 1.3. I've seen reference to a class called PTimer, but I can't find it. Nor can I find the pj.jar file which is supposed to contain PTimer.
    thanks,
    Harry Mitchell

Maybe you are looking for

  • IBooks not displaying pictures, why?

    I bought a book in iBooks. It's a book made for iBooks, but the pictures are not being displayed. What's wrong? I've already erased the book and downloaded it again, no success. Don't know what to do.

  • Target down, Agent Upload/OMS refresh rate

    Using 10.1.0.4.0 Grid Control,. OMS and all agents running on MS platforms. Currently testing agents, and in particular metrics and alert rates... The example I need to ask about is this... We have an agent running on a server, on which several targe

  • Best practices for EasyDMS Public Folder usage/management

    Hi,     We are implementing EDMS and are looking for best practices on the use of the Public Folder in EDMS.  We have different sites that have different business models, such as Engineer to Order or a "Projects" based business.  While other sites ha

  • Not a valid oci8 statement resource

    I've been grappling this problem sometime, google doesn't help because all the results I get are pages with the same error. Warning: oci_fetch(): 3 is not a valid oci8 statement resource in /home/dsk10/ugrad/bejhan/web_docs/facttable.php on line 21 L

  • Fullscreen across 3 monitor

    hi am pretty desperate... is there a way to open a projector i created (maximum 2800x768 in flash) which is as-ed to open fullscreen across 3 monitors, hitting a resolution of 3072x768?