?
Solved

NetScheduleJobAdd and NetRemoteTOD

Posted on 2003-02-22
7
Medium Priority
?
447 Views
Last Modified: 2010-04-04
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
Comment
Question by:freedumb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 8002975
I'll post You NetRemoteTOD() on Tuesday.
ziolko.
0
 
LVL 21

Accepted Solution

by:
ziolko earned 300 total points
ID: 8014399
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
 

Author Comment

by:freedumb
ID: 8048674
Thanks ziolko, that helps quite a bit. But for points I'm still looking for a NetScheduleJobAdd() example. Thanks.

0
Technology Partners: 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!

 
LVL 21

Expert Comment

by:ziolko
ID: 8055246
Sorry, but I dont have time to look at it at the moment. Maybe next week.
ziolko.
0
 

Expert Comment

by:CleanupPing
ID: 9317123
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
 
LVL 10

Expert Comment

by:kacor
ID: 9948215
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question