Hi,
Is there any hooks or other methods to run a custom script before any command is executed? I looked up and only found command-before-exec[COMMAND_ID] hook.
Thanks!
I don’t think there is such a hook. All available hooks are listed here:
What do you want it use it for?
I want to check for some system settings to allow user to execute a command or deny them, such as checking for computer name, pc & network information…
One appoarch is making a decorator in lib
folder and then apply it to every command’s main()
, but that’s not centralized.
I would create a function in lib folder and use it in all hooks (command-before-exec) which should be allowed or denied. I log suspicious actions of users this way.
Would this work for you?
This is similar and worked for me: Command-exec hook - #3 by eprunty
if correct system settings found:
execute postable command
else:
do something else
@davidvadkerti That’s what I’m doing. But I want one more layer of abstraction to normal users so I want to put it in a lib and compile it to a dll
@eprunty That’s only applied to one command per file. I want a universal hook for every command.