Accessing Win32 CreateEvent / SetEvent from WSH or another native Windows program

I need to interact with a software package that uses named. Win32 events (such as CreateEvent()

API) for communication between running processes.

I can do it with very simple C code

 h = CreateEvent(NULL, FALSE, FALSE, argv[1]);
 if (h != INVALID_HANDLE_VALUE) SetEvent(h);

      

However, due to policy issues, I am unable to install custom binaries on production machines!

Is there a way to do this using Windows Scripting Host?

I could get signed binaries added to the production environment, so another scripting language might be viable. Recommendations are appreciated.

0


a source to share


3 answers


If you just need Win32 event for regular events, you can use PowerShell. This will give you access to the .Net framework. This will allow you to indirectly access the API using a managed event class such as ManualResetEvent. It is just a thin wrapper on top of the regular CreateEvent APIs.



+1


a source


I can't install custom binaries on production machines! ... I might get signed binaries added to production

Sign your own binaries.



Whoever has set up this policy to run arbitrary WSH programs but not binaries must pay for your code signing certificate.

+1


a source


Python has a library called PyWin32 that allows you to use Windows API functions, including CreateEvent / SetEvent.

In general (and with varying levels of convenience) you can use any language that allows you to define and call external functions (in this case, from the kernel32.dll file).

0


a source







All Articles