devxlogo

API for NT Command Scheduler?

API for NT Command Scheduler?

Question:
How can I program the NT Command Scheduler (AT command) using VB5? What are the API calls? Right now I’m just using Shell to run AT. Is this my only option?

Answer:
This is a very simple example that should show you what you need to know to use the AT scheduling API:

Private Const JOB_RUN_PERIODICALLY       As Long = &H1&Private Const JOB_RUNS_TODAY             As Long = &H4&Private Const JOB_ADD_CURRENT_DATE       As Long = &H8&Private Const JOB_NONINTERACTIVE         As Long = &H10&Private Type AT_INFO   JobTime                             As Long   DaysOfMonth                         As Long   DaysOfWeek                          As Byte   Flags                               As Byte   Dummy                               As Integer   Command                             As LongEnd TypePrivate Declare Sub NetScheduleJobAdd _   Lib "netapi32.dll" _   (ByRef ServerName As Byte, _    ByVal Buffer As Any, _    ByVal JobID As Long)Public Sub Test(ByVal xi_Time_ms As Long)   Dim p_lngJobID                      As Long   Dim p_bytServerName()               As Byte   Dim p_typAT_Info                    As AT_INFO   Dim p_strCmd                        As String   Dim p_lngPtrToType                  As Long      p_typAT_Info.JobTime = xi_Time_ms ' Milliseconds past midnight   p_typAT_Info.DaysOfWeek = 0&   p_typAT_Info.DaysOfMonth = 0&   p_typAT_Info.Flags = 0&   p_strCmd = "CMD.EXE"   p_typAT_Info.Command = StrPtr(p_strCmd)      p_bytServerName = vbNullChar   p_lngPtrToType = VarPtr(p_typAT_Info)      NetScheduleJobAdd ServerName:=p_bytServerName(0), _                     Buffer:=p_lngPtrToType, _                     JobID:=p_lngJobID                     End Sub

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist