84100

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

Question:

I need to interface with a program suite that uses named. Win32 Events (eg, CreateEvent() API) to communicate between running processes.

I'm able to do this with some very simple C code

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

However, due to policy issues, I can't install custom binaries on production machines!

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

I could possibly get signed binaries added to the production environment - so other scripting language might be viable. Recommendations are welcome.

Answer1:

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

Answer2:

<blockquote>

I can't install custom binaries on production machines! ... I could possibly get signed binaries added to the production environment

</blockquote>

Sign your own binaries.

Whoever instituted such a policy that allows you to run arbitrary WSH programs but not binaries should pay for your code-signing cert.

Answer3:

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

In general (and with different level of convenience), you could use any language that allows defining and invoking external functions (from kernel32.dll in this case).

Recommend

  • cmake MSYS Makefiles generator missing
  • DotNet version of Windows Scripting Host
  • How can I decompile Linux binaries from Windows?
  • OpenCL bytecode running on another card
  • How do you copy a MS SQL 2000 database programmatically using C#?
  • Extracting Remote endpoint Object from Spring websocket session
  • CFNetwork SSLHandshake failed (-9806) & (-9800) & (-9830)
  • Accessing Windows Azure Queues from client side javascript/jquery
  • Linux over commit heuristic
  • how to make vpython .exe using pyinstaller
  • Android NFC read Tags issue. Activity starts each time on data received
  • openssl handshake failed
  • How to resolve docker host names (/etc/hosts) in containers
  • Should I be afraid to use UDP to make a client/server broadcast talk?
  • ASPNetCore MVC Routing Let Server Handle Specific Route
  • Deploying a CodeRush plugin from the Community Site
  • What is the use of a session store?
  • Problem with Django using Apache2 (mod_wsgi), Occassionally is “unable to import from module” for no
  • hibernate sets dirty flag (and issues update) even though client did not change value
  • Using Laravel 5.4 pusher
  • Getting media player state in windows phone 7
  • OSX - always hide certain files
  • Compiling dlib on OS X
  • SonarQube: Cannot deactivate rule with missing quality profile
  • How to generate and display a QR Code in ionic 2
  • How to make jdk.nashorn.api.scripting.JSObject visible in plugin [duplicate]
  • With Hadoop, can I create a tasktracker on a machine that isn't running a datanode?
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Atlas images wrong size on iPad iOS 9
  • NHibernate Validation Localization with S#arp Architecture
  • Bug in WPF DataGrid
  • Sony Xperia Z Tablet not found by adb
  • Volusion's generic SQL folder, functionality
  • Javascript convert timezone issue
  • Redux, normalised entities and lodash merge
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • How do you join a server to an Active Directory (domain)?
  • how does django model after text[] in postgresql [duplicate]
  • need help with bizarre java.net.HttpURLConnection behavior