What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How can I execute a batch file as notification?

Votes:

0

I configured a notification at the PRTG to execute a batch file when something happened.

I selected the batch file as a notification and left the parameter field blank, but when testing this notification nothing happens and the batch file does not run.

bat batch cmd custom-exe custom-notification exe notification prtg test

Created on Mar 17, 2010 9:07:26 AM

Last change on May 5, 2010 8:32:39 AM by  Daniel Zobel [Product Manager]



8 Replies

Accepted Answer

Votes:

0

This article applies to PRTG Network Monitor 12 or later, as well as to previous (deprecated) versions

EXE Notifications: Aspects to Consider

For custom EXE notifications there are some aspects you must be aware of:

  1. The EXE (or batchfile) will be executed in the security context of the "PRTG Core Server" service. By default, this is the SYSTEM account. For the system account, interactive EXEs or batches are not allowed. You may need to set the account for the "PRTG Core Server" service to a different user account, but this account should have local admin rights. You can change the account running this service in the Windows Computer Management console ("Services").
  2. If your custom code relies on other files (e.g., DLLs, .NET framework, Windows PowerShell, etc.), you must copy/install these files onto the machine running your PRTG Core Server manually!
  3. To check your notification, use the Test link of the respective entry in the notifications list in the web interface under Setup | Account Settings | Notifications. This should run your Batch or EXE every time. If not, something is wrong.
  4. If you use powershell scripts: With Windows' default security settings for powershell scripts, your script must be digitally signed. Information about signing powershell scripts and the Execution Policy for scripts can be found in the following external resources:
  5. Make sure to always use full paths in the batch file.
  6. The notification script cannot open any windowed application and cannot be a windowed application itself. This is not possible because PRTG runs as a service.
  7. Use " " or ' ' to encapsulate parameters to EXE/script notifications (in the parameters fields in PRTG).
  8. For Powershell notifications, bear in mind, it depends on which version (32bit or 64bit) of the PRTG Core Service is running, if either the 32bit or the 64bit Powershell are used.

Created on Mar 17, 2010 9:47:37 AM by  Dirk Paessler [Founder Paessler AG] (11,025) 3 6

Last change on Feb 26, 2014 2:58:40 PM by  Torsten Lindner [Paessler Support]



Votes:

0

Hello,

I'm trying to run a batch file from the Notifications\EXE folder and it will not work. It is a batch file that calls the program PSexec (to remotely stop/restart a Windows service on another machine). I put a copy of the PSexec program in windows/system32 and if I manuallly run the batch file from Notifications/exe folder it works fine. The PRTG notifications "execute program" drop down shows the batch file by name, so I assume it's in the right place.

When I try to test it via the Notifications "test" button in PRTG it does not work. Nothing seems to happen. PRTG is installed on a Windows 2008 R2 Enterprise server (member server, not a DC). I changed the Core Server logon account to a domain administrators account. I'm assuming this would grant the appropriate "local admin" rights as described above.

Please advise. Thanks! Ted

Created on Dec 30, 2010 5:46:27 PM



Votes:

0

with notifications, the exe runs with the service account the core service runs with.

we will add the possibility to select an account the notification exe runs with in one of the next builds we put online.

Created on Jan 1, 2011 9:30:52 AM by  Aurelio Lombardi [Paessler Support]



Votes:

0

I am experiencing the same issue as Ted (above). Although I have set the core server to use an administrative logon, it still does not run the batch file, or any other file for that matter.

Has anyone ever got this working? I am keen to resolve this as I need to send an ASCII string to a COM port as part of a notification and so far I can only find a way of doing this by using a batch file.

The batch file runs fine when run manually. The machine is running Windows XP.

Created on Feb 22, 2011 4:27:38 PM



Votes:

0

A few more tips for batch-notifications:

  • Make sure to always use full paths in the batch file.
  • The notification-script can't open any windowed application or can't be a windowed application itself, this is not possible as PRTG runs as a service.

Created on Feb 22, 2011 4:54:42 PM by  Torsten Lindner [Paessler Support]



Votes:

0

Hello everyone.

I have the same issue tring to Run a batch file. I have investigated, it seems that PRTG DOES execute the batch file but WITH NO parameters.

A very silmple test I did is with this batch file: Echo %1% >C:\Message.txt

The file is created but it contains no parameter value in %1% variable, this argues that PRTG does not pass any parameters in .bat files.

I'm running a Windows 7 x64 OS with administrator account Please fix it, thanks.

Created on Apr 29, 2011 1:01:32 PM



Votes:

0

Which parameters do you pass on from PRTG (set in the Notifications)?

Created on Apr 29, 2011 2:22:13 PM by  Torsten Lindner [Paessler Support]



Votes:

0

I try to pass any listed parameters, the default ones, and I have seen on Process Explorer that they have passed, but in some way they are not passed to the batch file, very odd.

I have solved the issue circumvent it, now the parameters pass FROM the batch file in a custom file (using echo redirecting), so it needed me to create one different batch file for any notifications, and I have to parse the custom files to read the "message". A not so clean method, but it is the very only way that actually works, nowadays discovered by me.

If you have somewhat cleaner I will be more grateful, thanks!

Created on Apr 30, 2011 2:14:28 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.