• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

NetScheduleJobAdd and NetRemoteTOD

Hi, I'd like to schedule a task on a remote computer in the near future (2 minutes away). I've looked into these API's (NetScheduleJobAdd and NetRemoteTOD), but cannot get them to work. Points will go to whoever provides the first working example.
0
freedumb
Asked:
freedumb
1 Solution
 
ziolkoCommented:
I'll post You NetRemoteTOD() on Tuesday.
ziolko.
0
 
ziolkoCommented:
const
        LIB_NAME = 'NetAPI32.DLL';
        REMOTE_TOD = 'NetRemoteTOD';
        BUFF_CLEAR = 'NetApiBufferFree';


type

  PTIME_OF_DAY_INFO = ^TTIME_OF_DAY_INFO;
  TTIME_OF_DAY_INFO = record
    tod_elapsedt: DWORD;
    tod_msecs: DWORD;
    tod_hours: DWORD;
    tod_mins: DWORD;
    tod_secs: DWORD;
    tod_hunds: DWORD;
    tod_timezone: LongInt;
    tod_tinterval: DWORD;
    tod_day: DWORD;
    tod_month: DWORD;
    tod_year: DWORD;
    tod_weekday: DWORD;
  end;


  TNetRemoteTOD = function(UncServerName: LPCWSTR;var BufferPtr: PTIME_OF_DAY_INFO):Integer;stdcall;
  TNetAPIBufferFree = function(Buff: Pointer):Integer;stdcall;

var      remDT: TNetRemoteTOD;


procedure Valid:Boolean;
begin
end;

function RemoteDate(Server: string):TTIME_OF_DAY_INFO;
var lpServer: LPCWSTR;
    ret: Integer;
    todi: PTIME_OF_DAY_INFO;
begin
  if Valid then
    begin
      GetMem(lpServer,Length(Server)*2+1);
      try
        stringtowidechar(Server,lpServer,Length(Server)*2+1);
        ret:=remDT(lpServer,todi);
        if ret = NERR_Success then
          Move(todi^,Result,SizeOf(TTIME_OF_DAY_INFO))
        else
          CheckReturn(ret);
      finally
        FreeMem(lpServer);
        NetApiBufferFree(todi);
      end;
    end
  else
    raise Exception.Create('Unable to load '+LIB_NAME+' or function "'+REMOTE_TOD+'" not supported');
end;

if You want time from NT based system: RemoteDate('computername') but from Win9x: RemoteDate('\\computername');


ziolko.
0
 
freedumbAuthor Commented:
Thanks ziolko, that helps quite a bit. But for points I'm still looking for a NetScheduleJobAdd() example. Thanks.

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ziolkoCommented:
Sorry, but I dont have time to look at it at the moment. Maybe next week.
ziolko.
0
 
CleanupPingCommented:
freedumb:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
kacorretiredCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       the answers contains useful information, it would be mistake to delete,
       but the original question is not completely solved
       to accept ziolko's answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now