Using NetScheduleJobAdd with calldll.

Gurdon Merchant, Jr. gurdon_merchant at
Sun Oct 14 20:28:02 CEST 2001

Finally solved my problem.

The win32 definition of NetScheduleJobDel() is:

NET_API_STATUS NetScheduleJobDel(
  LPCWSTR Servername,  
  DWORD MinJobId,     
  DWORD MaxJobId      

"LPCWSTR Servername" is a pointer to a unicode string, not a string.

> I believe I'm passing the string with the PC name incorrectly.
So, yes I was passing the PC name incorrectly.

> # Following returned ERROR_SUCCESS=0 when trying to delete job
> # on local machine.
> pcName = windll.cstring('', 2)
This worked because Unicode is two bytes.  The '2' made things work locally
because regular ASCII is represented in Unicode as the second byte being
\x00.  So, windll.cstring('', 2) was in effect '\x00\x00' and so it worked
on the local machine.

Consider a remote pc called \\remotepc.  This must not be:
  pcName = windll.cstring('\\\\remotepc')
but rather:
  pcName = windll.cstring('\\\x00\\\x00r\x00e\x00m\x00o\x00t\x00e\x00\x00')

Then, everything works.

If windll accepted windll.cstring(u'\\\\remotepc') I could be really lazy.
Since it does not I'll just wrap up names that need to be unicode.

Thanks in advance,

Gurdon Merchant, Jr.
Gurdon_Merchant at

More information about the Python-list mailing list