Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than netapi32, prefix the name with the module name and a period.
NetScheduleJobAdd (netapi32)
.
C# Signature:
/// <summary>
/// Adds a windows schedukled task.
/// </summary>
/// <param name="Servername">
/// The name of the machine to add the scheduled task to.
/// NULL for localhost.
/// </param>
/// <param name="Buffer">A pointer to a AT_JobInfo struct.</param>
/// <param name="JobId">An output parameter.</param>
/// <returns>0 on success. An Error code otherwise.</returns>
[DllImport("Netapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int NetScheduleJobAdd
(string Servername, IntPtr Buffer, out int JobId);
VB Signature:
''' <summary>
''' Adds a windows schedukled task.
''' </summary>
''' <param name="Servername">
''' The name of the machine to add the scheduled task to.
''' NULL for localhost.
''' </param>
''' <param name="Buffer">A pointer to a AT_JobInfo struct.</param>
''' <param name="JobId">An output parameter.</param>
''' <returns>0 on success. An Error code otherwise.</returns>
<DllImport("Netapi32.dll", CharSet := CharSet.Unicode, SetLastError := True)> _
Friend Shared Function NetScheduleJobAdd(ByVal Servername As String, ByVal Buffer As IntPtr, ByRef JobId As Integer) As Integer
End Function
User-Defined Types:
/// <summary>
/// Info for a scheduled task.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal struct AT_INFO
{
/// <summary>
/// Time the job is run. Expressed in milliseconds from midnight of the day the
/// job is to be run.
/// </summary>
public uint JobTime;
/// <summary>
/// Bitmast of days of the month that the job is to be run.
/// Bitmask is from the first to thirty first, lowest to highest bit.
/// </summary>
public uint DaysOfMonth;
/// <summary>
/// Bitmast of days of the week that the job is to be run.
/// Bitmask is from Monday to Friday, from lowest to highest bit.
/// </summary>
public byte DaysOfWeek;
/// <summary>
/// Flags to specify info about the jobs.
/// </summary>
public AT_JobFlags Flags;
/// <summary>
/// The command to run.
/// </summary>
[MarshalAs(UnmanagedType.LPTStr)]
public string Command;
}
This will add a scheduled task using the older api that AT.EXE uses. Because of this, you will not be able to name the scheduled task.
Tips & Tricks:
Please add some!
Sample Code:
Please add some!
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).