Using NetScheduleJobAdd with calldll.

Gurdon Merchant, Jr. gurdon_merchant at ml.com
Fri Oct 12 09:06:10 EDT 2001


I've used Sam Rushing's calldll tool to do some simple Win32 API
calls.  However, I've failed to use it properly in calling the
NetScheduleJobDel() API.  I realize I can manipulate jobs in other
ways but wish to use calldll despite that fact.

I believe I'm passing the string with the PC name incorrectly.  Could
someone point out my error?  The C definition of NetScheduleJobDel()
is rather simple and is located at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/ntlmapi2_7gz0.asp

# Problem: When I use calldll to invoke NetScheduleJobDel() to delete
#   an at job it only works when specifying the local PC via a null
#   for the name.  If the name of the local PC or a remote one is
#   used it fails.  Is not a rights problem. Believe I'm not passing
#   in the PC name to NetScheduleJobDel() correctly.
#
# Assumption: 'at 10:00 /every:m foo' or some other variation was
#   done to create an at job entry on an NT system.  Note the job
#   number and pass in as parameter one.
#

# Sam Rushing's module for generic API calls.
import windll

# Get a pointer to the NT DLL with the NetSchedule* APIs used to
# manipulate the scheduler.
netapi32_dll = windll.module('netapi32', '.dll')        

# Grab the job number to delete from parameter one.
import sys
jobNumToDelete = int(sys.argv[1])

# Following returned ERROR_INVALID_NAME=123 when trying to delete
# job on local machine.
# pcName = windll.cstring('')

# Following returned ERROR_SUCCESS=0 when trying to delete job
# on local machine.
pcName = windll.cstring('', 2)

# Following returned ERROR_BAD_NETPATH=53 when trying to delete job
# on remote machine.
# pcName = windll.cstring('\\\\remotepcname')
# Same result when specifying the local PC by name:
# pcName = windll.cstring('\\\\localpcname')

errorCode = netapi32_dll.NetScheduleJobDel(
    pcName.address(),
    jobNumToDelete,
    jobNumToDelete
  )

print 'NetScheduleJobDel returned', errorCode





Thanks in advance,

Gurdon Merchant, Jr.
Gurdon_Merchant at ml.com



More information about the Python-list mailing list