New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


EXE Sensor: EXE Called from a batch file fails to run with error "[exe name] is not recognized as a

Votes:

0

Your Vote:

Up

Down

I've written a CMD file as a PRTG sensor to check a temperature sensor that has a simple text web page that reports the temperature in a rack of equipment.

Here's my script: {{{@echo off for /F "tokens=1,3* delims=| " %%i in ('c:\windows\system32\curl.exe -s http://url.local.lan/temp') do set temperature=%%j

if %temperature% gtr 82 goto error if %temperature% gtr 78 goto warning if %temperature% gtr 60 goto good

:: catch all for anything under 60 echo %temperature%:Other exit 3

:error echo %temperature%:Error pause exit 2

:warning echo %temperature%:Warning pause exit 1

:good echo %temperature%:Ok pause exit 0}}}

I can run it from the command line on the probe and it works perfectly. I've put the curl.exe into the path (c:\windows\system32) and called it both by full path, and just by name (i.e. "curl").

I've tested with the PRTG probe running as my own admin user account. Each time i get the error:

'c:\windows\system32\curl.exe' is not recognized as an internal or external command, operable program or batch file.

I've tried moving my EXE commands to variables like this: for /F "tokens=1,3* delims=| " %%i in ('%1 %2 %3') do set temperature=%%j And then pass the parameters from within PRTG sensor setting, but get the same error.

PRTG Sensor is set to run as "Use security context of probe service"

NOTE: I attempted to use PowerShell and "Invoke-WebRequest" but the temperature sensor is old (Sensatronics TempTrax E4 circa 2003) and uses non-standard html formatting so PowerShell refuses to parse it correctly. Hence the use of curl.exe.

cmd custom-script-exe custom-sensor exe prtg sensor

Created on Mar 22, 2018 2:43:42 PM by  NetCaptive (0) 1



3 Replies

Accepted Answer

Votes:

1

Your Vote:

Up

Down

Most likely, the issue is due to the fact your probe is a 64-bit operating system

PRTG Probe.exe is a 32-bit process; as such, when you run it it will look for curl.exe in C:\Windows\SysWOW64. Windows automatically redirects requests against system32 from 32-bit processes to SysWOW64, which contains the 32-bit versions of the executables they're interested in

To target processes in C:\Windows\system32 from a 32-bit program you need to target C:\Windows\sysnative\curl.exe. Otherwise, you can put a copy of curl.exe in SysWOW64, or just move it out of system32 entirely

Created on Mar 23, 2018 5:41:22 AM by  lordmilko (1,192) 2 1



Votes:

0

Your Vote:

Up

Down

Thank you for chipping in, lordmilko.

What might also work is putting curl.exe into the same folder as the script the sensor runs.

Kind regards,

Erhard

Created on Mar 23, 2018 11:58:21 AM by  Erhard Mikulik [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Copying curl.exe to C:\Windows\SysWOW64 did the trick. Thanks!

Created on Mar 23, 2018 1:15:03 PM by  NetCaptive (0) 1



Please log in or register to enter your reply.


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.