Create A Scheduled Task
Is there a way to interface with the Windows Scheduled Task Manager to create a new task that runs hourly?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Create Scheduled Task Thru VB
Hi all,
Does anyone know how to create a Scheduled Task thru VB ?? The Task wizard creates an encrypted file in the WindowsTasks folder that has the extension of JOB. I figure it's along the lines of creating a Shortcut but I searched codehound and others and came up empty.
Thanks in advance.
John
How To Add A Scheduled Task
How do you add a program to run at a certain time using VB, to be a scheduled task?
I want this done automatically using VB if at all possible.
Scheduled Task
I am trying to create a scheduled task from within my application (AT command). Does anyone know how i can do this.
Scheduled Task Problem
From a scheduled NT Task i am calling a access database, which inturn then calles a a batch file using the Shell command to connect to a ftp server and transfer a file.
When I run this from access it workes fine, however when I run the scheduled task it hangs when trying to open the ftp server.
Any ideas why this is happening, and is it possible to send the ftp commands from within Access VBA?
Any suggestionshime would be wolcomed.
Creating A Scheduled Task
Does anyone know of a way to create a Windows 2000 Pro scheduled task within a VB6 application? Is it possible?
Thanks!
JC
Creating A Scheduled Task
Hi all,
I've searched the forums, but nothing really stuck out to me. I want to automatically create a scheduled task of my application. I have this code, but it's not working correctly:
Code:
Option Explicit
Private Declare Function NetScheduleJobAdd Lib "NETAPI32.dll" (ByVal servername As String, Buffer As Any, ByRef JobId As Long) As Long
Private Type AT_INFO
JobTime As Long
DaysOfMonth As Long
DaysOfWeek As Byte '127 = all days (01111111b)
Flags As Byte
Command As String
End Type
Private Const JOB_RUN_PERIODICALLY As Long = &H1
Private Sub cmdAddTask_Click()
Dim ai As AT_INFO
Dim t As Date
Dim apiTime As Long
Dim strFile As String
strFile = "G:luecardQueue CleanerCleaner.exe"
'check for invalid time
On Error Resume Next
Err.Number = 0
t = CDate(txtDept.Text)
If Err.Number > 0 Then
MsgBox "Invalid Time!"
Exit Sub
End If
On Error GoTo 0
apiTime = (Hour(t) * 3600 + Minute(t) * 60) * 1000 'convert to milliseconds
ai.JobTime = apiTime
ai.DaysOfWeek = 127
ai.Flags = JOB_RUN_PERIODICALLY
ai.Command = StrConv(strFile, vbUnicode)
'the null 'servername' parameter uses the local computer
NetScheduleJobAdd vbNullString, ai, 0&
End Sub
This will create the task, but the task will never run.
Wont Run As Scheduled Task
Hi There,
I have written a program to run on a windows2000 server. It is designed to connect to an ACT! database to create a CSV file of certain records. The program works correctly if i launch it from the exe. if i run the exe with the command line parameter autorun it does it automatically, this also works. But if i create a scheduled task with the command line paramater autorun it does not. as far as i can tell the process loads but does not do anything.
Please provide me with any suggestions as to what may be causing this.
Kind Regards
SkreeM
Verify Scheduled Task Ran
Is there a way to code a VB project to verify a scheduled task ran? I don't want to set up any file updates from the scheduled application to check. I just want to check Windows some how to verify it after the first project ran. I'm using Windows 2000 Professional.
Basically it's running on a remote computer and I want to set it up to send me an email if it's predecessor didn't run.
Delete A Scheduled Task
hey guys i was wondering, how to delete a job that was created uding vb? i'm using the at command to make the job
Scheduled Task Not Working
I have a job that was added to Windows Task Scheduler through NetScheduleJobAdd, but they do now run at the specified time. It seems that it does not like directory paths with spaces in the name(i.e. "Program Files"). Is there a way around this? The only two solutions I could think of is either make a shortcut in the root directory or add the directory path to the path environment variable.
Scheduled Task ERROR. Please HELP
I want to make my program run at a cetrain time, so I search thru this forum, and found that I should add the program in the scheduled task.
But I get the error and can't start the program.
Is there anything that I have to do make this work?
I attached the screen shot of the error I got.
Could anybody help me with this?
Thank you very much.
Scheduled Task - Can't See Printers
When no one is logged on and I run a VB program via NT Scheduled Tasks,
the VB program cannot see any printers, even though it
logs in via WNetAddConnection2 and the login parameters
provided to "Scheduled Task".
Also, word needs to be able to see the printers, as well.
Scheduled Task Does Not Instantiate Excel
I have some VB 6.0 code that looks through an Access 97 database and exports various records to an Excel 97 spreadsheet. The code I use for opening the Excel is as follows:
Set xlApp = New Excel.Application
'---
'Open Excel
'---
Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Add
Set xlsSheet = xlApp.ActiveWorkbook.Sheets(1)
xlApp.Visible = False
When I run the code from the server (logged into the server) the code works great. However, when I schedule the task to run at night the code breaks at the Set xlApp = New Excel.Application line.
I set the security on the Scheduled task to run as the same user that works when I am logged into the system.
I'm at a loss...Please help.
Scheduled Task In Windos 2000
Hi there!
I am currently runing my application in Windows2000 Scheduler for 24hours every mminute.
My Problem is.. When I change the timezone in PC programatically the Scheduled Task seems to not recognize the next run time?
Is there a setting for this to be done?
So that it will still be running 24 hours?
IANIAN
Running Scheduled Task From .vbs File
Hi there.
I have created a scheduled task that I would like to be able to run by dbl clicking a .vbs file (with code to run scheduled task). Trouble is I don't know the code to run the task so can anyone help.
Thanks a lot
James Brown
Running A Scheduled Task From ASP Page
Hi,
I have a scheduled task that runs at the appointed time fine. Now, in my web app (ASP,VBScript) I'd like a user to be able to click a button which would actually run the scheduled task using an onClick event).
so, something like:
<a href="#" onClick="runScheduledTaskFunction()">RUN</a>
Can this be doe?
Thanks a lot
Tony Mead
Scheduled Task With DIWriteJpg Method
Hi,
I am using Declare Function DIWriteJpg Lib "DIjpg.dll" (ByVal DestPath As String, ByVal quality As Long, ByVal progressive As Long) As Long and Public Declare Function ConvertBMPtoJPG Lib "JPGUtils.dll" (ByVal strFileName As String, ByVal JPGCompressQuality As Integer, ByVal blnKeepBMP As Boolean) As Integer to convert bmp images to jpg images.
I want the program to run as a scheduled task. When I run the program locally, it behaves the way it should and creates the jpg images at my specified location! BUT, when I put it in a scheduled mode, by passing command line argument, my whole project disappears (i.e., the application crashes), while trying to use
the "DIWriteJpg" function.
I am not able to figure out what is the possible connection between being run as a scheduled task and using the "DIWriteJpg".
Any input would be helpful!
Thank you,
Regards,
Swati Shukla
SQL Server Scheduled Task Behaving Weird
Hi,
I am facing a really weird problem working with SQL server.
I have a stored procedure with an insert query. This procedure has been scheduled and running fine for last 10 months. For last 2 days, when I execute it in query analyzer, it returns about 1 or 2 rows according to the data, which is the way it is supposed to be. When the same procedure (without any single change even in comments)
is executed as a scheduled task, it returns more than million rows in stread of 1-2 rows as if it has created full outer joins on the tables in the query.
We are running sql server 7.0 with SP2. No problems with servers are noticed in last week. I dropped and recreated the procedure several times if in case execution plan has gone bad. The create procedure statement has 'with recompile' condition also.
Has anyone seen this kind of problem with sql server before?
Can anybody give a logical explanation for this? Does the SQL server handles procedures differently in SQL server and as a scheduled task? This has created more than enough problems for me at work as emails are sent to the outsiders from the data inserted in the table. It might create legal problems for the company also as the program ended up sending several thousand emails to the people who has nothing to do with it. So, any explanation will be appreciated.
Here is the query:
insert into MKS_failed_notify_wrk
select es.shopper_id,
ds.first_name,
ds.last_name,
ds.email,
ds.employee_id,
dop.order_id,
dop.pin_id,
dop.product_ppn,
es.exam_score,
es.passed_exam,
dct.exam_date,
dct.online_exam_id,
0,
'1/1/1900'
from exam_result dct,
exam_selected es,
order_output2 dop,
shopper ds
where dct.exam_date > dateadd(day, -4, getdate())
and es.online_exam_id = dct.online_exam_id
and es.EXAM_SCORE < 66
and es.order_id = dop.order_id
and dop.product_ppn like '300477%'
and ds.shopper_id = es.shopper_id
and es.exam_code in ( 'ECE47701','ECE47702')
and dop.pin_id = 'MKSDNS'
Please let me know if you can think about any reason for this behaviour.
Thanks,
Ann
Datareport Won’t Print From A Scheduled Task
I have a VB 6.0 SP6 application that processes order files. It is setup to run either unattended as a scheduled task with a command line parameter or via a form interface. The appl generates a report at the end of the run via a Datareport designer.
Now the bug…
When I run the appl via the form interface (or from within the VB source environment to debug) it processes normally and generates the report.
When I run the appl via a scheduled task on my machine it processes the data but doesn’t print the report. The scheduled tasks are created using my own network credentials (which are in the domain admins group by the way) as the RunAs parameters. Nothing appears in errors.log that is typically created in the installation directory when there’s a problem. I also have had the printer queue opened and don’t see anything passing through.
I’m wondering if anyone has experienced this and identified a work around. I’m thinking it’s a part of the XP Scheduled Task process but I have full control rights to my own machine.
Gurus??? Please Help... Scripting The Creation Of A Scheduled Task In ASP With WMI
This may not be the right forum for this question, but I wasn't getting any responses in the ASP forum (so I moved the question here)...
I am attempting to create/delete Scheduled Tasks on our web server from a website running on that server. I have an ASP page that gathers all the scheduling details from the user and passes them to another ASP page that writes most of these details to an Oracle table and then calls a function in a VBS page that schedules the task.
After searching Google and MS it appears that the ‘Task Scheduler’ APIs cannot be scripted, but the ‘AT’ APIs can. (http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/scrguide/sas_man_lpja.asp).
The page referenced above makes the following statement regarding the user allowed to run scheduled tasks (it isn’t explicit about who can CREATE a task)…
“Tasks must run under the same account as the scheduler service. By default, this is the LocalSystem account, although you can configure the service to run under a different account.”
I don’t think I want to change the account that Scheduled Tasks run under by default on the server…
I found the following code (on one of MS’s sites and several other places), but I have had a heck of a time trying to get this to work due to 'permissions issues'.
(http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/scrguide/sas_man_lpja.asp)
Code:
sComputer = "."
Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & sComputer & "
ootcimv2")
Set oJob = oWMIService.Get("Win32_ScheduledJob")
errJobCreated = oJob.Create("C:WINDOWSNotepad.exe", "********123000.000000-420", True , 1 OR 4 OR 16, , , JobID)
If (errJobCreated = 0) Then
Response.Write("New Job ID: " & JobID)
Else
Response.Write("An error occurred: " & errJobCreated)
End If
I was originally getting an 'Access Denied' error when I attempted to set the oWMIService object with the 'GetObject' command. However, I finally found that the issue had to do with user security on WMI itself. I granted rights to the IWAM user on WMI, and this problem went away.
Now, however, when I try to create a job (a Scheduled Task) I get an error ‘2’ returned from oJob.Create. Error number 2 = "The user did not have the necessary access".
I have tried adding the IWAM and IUSR users to the Admin group. I’m not sure where to go from here???
We are running IIS 5.1 and the web site’s ‘Directory Security / Authentication Methods’ are set to ‘Anonymous Access’, ‘Allow IIS to control password’ and ‘Integrated Windows Authentication’.
I am developing on an XP Pro box, but the production environment is a W2K server.
Any help would be greatly appreciated (although I wouldn’t want anyone to spend much time at all on this… after reading more about the limitations of tasks created by AT.exe I’m not positive that I want to use this method anyway. I have a 3rd party piece of software that I have been successful in using to accomplish what I’m trying to do. It would just be nice to not have to mess with that software and licensing, etc.)
Rob Milton
Edited by - rob_milton on 1/15/2004 3:03:07 PM
Running A VBA As A Scheduled Task. Batch File That Is
My first post. I usually find answers without posting.
Here is what I want to do:
I want a VBA script in a workbook to run at night.
My test set up:
In Windows XP I made a schedule task to open a workbook called batchtest.xls
In the workbook "batchtest.xls" I have this code on the "ThisWorkbook"
Private Sub Workbook_Open()
Application.Run "'code.xls'!mapkeytest"
End Sub
This executes when the workbook is open by the task scheduler.
It is suppose to call the macro "mapkeytest" that is in a module in the workbook "code.xls"
What happens is that when the Task Scheduler tries to open the "batchtest.xls" Excel pauses and brings up a message box "File in use" that states "PERSONAL.XLS is looked for editing by username" It gives the choices of "Read only", Notify, Cancel. If the Read only is selected it runs fine. This does not work for automation. I don't see any reference to the personal book by the other two. Now, if Excel is not running at all, it works fine. Maybe this is a Windows OS problem.
Any suggestions??
Thanks
Problem With Setting Start Date For A Task Scheduled.
I am using :Win32_ScheduledJob Class for scheduling a certain task using Visual Basic .I am able to schedule the task with the parameters specified in the class.But I am not able to set the start date for the task created.How to set the start date and end date of a task in Visual Basic program?
Application Is Not Working As Scheduled Task But Running With RunAs
We have developed an application in vb which access exchange public folders
and mail box using CDO 1.21 library.
I am able to run this application using RUNAS command with domain account,
but the same application is not working when it is scheduled with the same
domain account. I am getting overflow error
The scheduled task is working when the current logged on user is same as the
scheduled user.
Any Idea regarding this behavior?
Advance Thanks,
Ramana & Anil
Create Scheduled Tasks In Code
I'm using vb6 (service pack 6) to create an application that has the option of giving the user the ability to periodically back up their database at a certain time and a certain day. I was delighted when I found the use of the "AT" command that could be used inside of a Shell command to do exactly what I wanted. But I made the crucial mistake of developing on winXP without checking previous OS's for compatibility. I know "AT" is not something Win98 reconizes and I was hoping someone knew if ME or 2000 has it. Since my immediate concern is my win98 user I wanted to know if there was any other commands that could be used to schedule a tasks in win98 without actually developing a module that works with the windows API. If not has anybody gotten NetScheduleJobs (http://www.planet-source-code.com/vb...47254&lngWId=1) to work with their code ? This was the best code I could find for dealing with the API, unless someone knows of a better one.
Create A Scheduled Email In Outbox
Hello everybody
I need to create a macro which creates an email
in the outbox which will not be delivered before
a ceratin date (do not deliver before).
Any help will be appreciated
Rafael
Create Scheduled Tasks Using Visual Basic
I want to create a program that allows me to set up a scheduled task for Windows, to run another program. I have searched all over the internet looking for a way to do this, but I cannot find one.
Does anyone know how I can create a Windows Scheduled task with all my variables for time and such?
Create Windows Scheduled Tasks Automatically Using VB
Dear All,
My Goal is to create a form where users can specify their scheduling requirements in various fields and then click a button, which will create the windows scheduled task for them to minimise user involvement.
I've searched around and can't seem to find any sample VB code to work from as the Microsoft reference is all in C++.
If anyone has done something similar and could point me in the right direction on this I would be very grateful.
Many Thanks
Ben Cooper
Can I Create An Outlook Task From Access??
This is what I'm wanting to do...
I have an access database which collects all sorts of data. If a date entered is more than 2 weeks away I want a task in outlook to be created to with a reminder 2 weeks before that date.
I have been playing with this procedure (which works fine in an outlook macro):
Public Sub CreateTask(strSubject As String, strBody As String, strCurrentUser As String, DueDate As Date, RemindDate As Date)
'Dim itmTask As TaskItem
Set appOL = CreateObject("Outlook.Application")
'create a new Task
Set itmTask = appOL.CreateItem(olTaskItem)
With itmTask
.Subject = strSubject
.Body = strBody
.Importance = 1
.Owner = strCurrentUser
.StartDate = DueDate
.DueDate = DueDate
.ReminderSet = vbTrue
.ReminderPlaySound = vbTrue
.ReminderTime = RemindDate
'Save and close without prompting
.Close (olSave)
End With
End Sub
But it doesn't like setting the owner or start and due dates... why?
Create Outlook Task VBScript On The Web
I am trying to Create an Outlook Task over a webpage..
I have an example - www.revonex.com/tasks.html
You can look at the source code. When I save it to my local drive it works fine, but when I try to run it from there I get an error...
Here is the code - any suggestions??
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<FORM NAME="frmTask">
<INPUT TYPE="Button" NAME="cmdClickMe" VALUE="Click Me" STYLE="WIDTH: 185px; HEIGHT: 42px" SIZE=63>
<SCRIPT FOR="cmdClickMe" EVENT="onClick" LANGUAGE="VBScript">
Dim objOutlook
Dim itmTask
Dim datDue
Dim strMsg
Dim strMsg1
Set objOutlook = CreateObject("Outlook.Application")
Set itmTask = objOutlook.CreateItem(3)
' Query the User for a Subject
itmTask.Subject = InputBox("Enter the task subject:", "Subject")
' Query the user for the Body Text
itmTask.Body = InputBox("Enter the task body text:", "Body")
' Handle case if/when user supplies no Subject. Assume user is
' aborting his request to create a new task.
If Len(itmTask.Subject) = 0 Then
' User hit Cancel or didn't type any text
' There is no task to save
strMsg = "No Task information provied." & vbcrlf & vbcrlf & "Operation aborted by user."
MsgBox strMsg, ,"Aborted"
Else
' Query user for Due Date
datDue = InputBox("Enter the due date:", "Due Date",Date())
If datDue <> "" Then
itmTask.DueDate = datDue
End if
itmTask.save
strMsg1 = "Your task has been saved."
MsgBox strMsg1, ,"Success!"
End If
' Clean up
Set itmTask = Nothing
set objOutlook = Nothing
</SCRIPT>
</FORM>
</BODY>
</HTML>
Create Outlook Task From VBA Code In Access
Hi all!
Does anyone have any idea how I can create a Task (with due date, reminder...all the "bells and whistles") in Outlook from VBA code in an Access database.
Basically, work is defined in the database and I want the code to create the Task as a reminder to the person who the work is assigned to. (Did that make any since!?)
Both Access and Outlook will most likely be open when this code is run.
Thanks!
How To Create A Job In Task Scheduler With Specific Interval (repeat Time)?
Hi,
How to create a job in task scheduler with specific interval (repeat time)?
Upon visiting numerous sites I could manage to create a task for required time.
But to set the interval of repeat?
My script goes like this:
Const MON = 1
Const TUE = 2
Const WED = 4
Const THU = 8
Const FRI = 16
Const SAT = 32
Const SUN = 64
strComputer = "."
strCommand = "c:TestLog.exe"
strstartTime = "********233000.000000-000"
boolRepeat = True
intWeekDay = MON Or TUE Or WED Or THU Or FRI Or SAT Or SUN
intMonthDay = ""
boolInteract = True
Set objWMI = GetObject("winmgmts:\" & strComputer & "")
Set objNewTask = objWMI.Get("Win32_ScheduledJob")
intRC = objNewTask.Create(strCommand, _
strstartTime, _
boolRepeat, _
intWeekDay, _
intMonthDay, _
boolInteract, _
intJobID)
Now I want this task to execute every 30 minutes upto 11 PM.
How to do it?
Please help. Any sort of help is appreciated.
Thanks
-Srinivas
How To Create A Job In Task Scheduler With Specific Interval (repeat Time)?
Hi,
How to create a job in task scheduler with specific interval (repeat time)?
Upon visiting numerous sites I could manage to create a task for required time.
But to set the interval of repeat?
My script goes like this:
Const MON = 1
Const TUE = 2
Const WED = 4
Const THU = 8
Const FRI = 16
Const SAT = 32
Const SUN = 64
strComputer = "."
strCommand = "c:TestLog.exe"
strstartTime = "********233000.000000-000"
boolRepeat = True
intWeekDay = MON Or TUE Or WED Or THU Or FRI Or SAT Or SUN
intMonthDay = ""
boolInteract = True
Set objWMI = GetObject("winmgmts:\" & strComputer & "")
Set objNewTask = objWMI.Get("Win32_ScheduledJob")
intRC = objNewTask.Create(strCommand, _
strstartTime, _
boolRepeat, _
intWeekDay, _
intMonthDay, _
boolInteract, _
intJobID)
Now I want this task to execute every 30 minutes upto 11 PM.
How to do it?
Please help. Any sort of help is appreciated.
Thanks
-Srinivas
Windows Task Scheduler - Add A Task
Does any body have any idea how to add a task to the windows task scheduler (if its not there already) through a vb program ?
So that a program can be run through the task scheduler...
(By the way, I know how to do it manually, I just want to put a task to the scheduler through a vb program)
Thanks
Ram
Please HELP!!! Add Task To Windows Task Schedular
I have a application written in VB 6.0.
I want to add my application to the Windows Task Schedular in prgramatically.
So everytime, if the PC is turned on, the application execute, for example 10:00AM every morning. So within the code I 'm going to specify to add my application to the Windows Task Schedular to execute every morning 10:00AM, if the PC is turned on.
I'm greatly appreciate if anyone can give me an idea how to do this. I really appreciate.
Cheers
Raj
IP Scanning For Scheduled WOL App
hi everyone,
Im new to the forum, as well as to "intermediate-advanced" vb programming, so Id appreciate any help you guys could offer.
Ok, so Ive been looking everywhere for a freeware Wake On LAN/network admin tool for the SOHO LAN Im in charge of, but I havent found anything free&good, so I want to build it myself. Basically, I want something that will send scheduled WOL wake-up packets to the office computers early in the morning to auto-boot them all up before the employees get there. Ive already found a free control that will create/send the packets given a MAC address, and Ive also found some code snippets that show how to translate a given IP into a MAC. So, all I need is to work on is figuring out how to "schedule" the packets and leave the program running in the server system tray(id appreciate any hints/advice on doing this...) and doing the IP scan for active hosts.
I want to add an option to the program that will automate the MAC address discovery&storage function, by clicking a button, and automatically scanning a small IP range (last block; ex.192.168.1.2 --->192.168.1.254) for active hosts, resolving each mac address, saving the MAC's, and adding them to the "WOL list" for the next morning. This way, I can auto-generate the WOL list during regular biz hours, and not have to set up each MAC manually. Theres probably only about 50 or less machines on the net. I dont even know where to start with the IP scan. Id appreciate any help anyone would be willing to offer.
Scheduled Event
Is it possible to schedule an event based on time or day and have it execute WITHOUT intervention from the user?
Namely, I want to scan a directory on a regular basis and delete files meeting some criteria. I also want to End the program at a given time every day (I am not concerned about unsaved data).
Thanks for any input or reference.
H. Chain
Houston, TX
|