Send messages to windows event log?

Has anyone managed to send messages to windows event log from script?

Thanks in advance!

You could probably pair system.util.execute with the eventcreate builtin function: https://www.windows-commandline.com/create-event/

Keep in mind script execution scopes - if you call your script from a Vision button, it’ll go into the local machine’s logs, not the gateway’s; you’ll have to use something like system.util.sendMessage if you want to send an event to the gateway to go into a central event viewer.

I've tried that and the problem is that i need to run eventCreate via cmd which need to be run as administrator. That where it fails!

Hm, even from the gateway scope? I would expect the gateway service to be able to interact with it even when running as ‘LOCAL_SYSTEM’.

A bit of a hacky workaround:

  • create a .BAT file with elevated privileges to run cmd
  • use system.util.execute to run the .BAT file

I think I have to give up on this one, I’ve tried with elevated privileges and I get prompted “Do you allow this app to make changes”. Since I’m not allowed to turn off the notification in windows I assume it wont work.

Thanks for your efforts!