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

Restart a remote service

Votes:

0

I have tried a similar approach to https://www.paessler.com/knowledgebase/en/topic/453-how-can-i-reboot-a-computer-with-a-wmi-call but with restarting a service on a remote computer.

Unfortunately, it does not work from within PRTG monitoring service. I have multiple versions (WMI, Powershell, Sysinternals) but all have the same problem. It is on a Windows 2008 R2 server and I think it has something to do with the fact that the notifications folder is a sub-folder of the program files.

The manual start of these versions do the job well, only when trigger from within PRTG it does not work.

Does someone have a solution for me?

I will upgrade the software from 7.2.4.5051 to the latest version.

Mario

custom-notification notifications service wmi

Created on Jul 30, 2010 7:39:16 AM

Last change on Jul 30, 2010 7:43:32 AM by  Daniel Zobel [Product Manager]



9 Replies

Accepted Answer

Votes:

0

PTF Launcher

If the computer running the service has to be restarted has a user logged in, you can use PTF Launcher to start "net start <service>" on the specified computer in order to start the service.

Use the -c= parameter to specify the computer that has PTF Launcher running.

Enter the following parameters in the parameter section of the Launcher Custom Notification

-c=192.168.1.1 -s=net.exe -a=start <service>

Alternatively you can have PTF Launcher run a batch file that first stops the service with "net stop <service>" and than starts it again with "net start <service>".

@echo off

rem stop the service
net stop %1% > null

rem wait 2 seconds
ping 1.1.1.1 -n 1 -w 2000 > null

rem start the service
net start %1% > null

Save this file as restart.bat and use:

-s=c:\path_to_batch_file\restart.bat -a=sharedaccess

...to restart the Windows Firewall service.

Please see the readme.txt that is included in the download for more information.

Created on Aug 5, 2010 6:40:30 PM

Last change on Dec 12, 2013 5:35:19 PM by  Gerald Schoch [Paessler Support]



Votes:

0

Hello,

I'm trying to use this same scenario to launch a batch file via the Launcher app on my PRTG server.

-s=c:\path_to_batch_file\restart.bat 

When I do this, I see a quick flash of the cmd prompt, but it doesn't run and immediatly closes. I can run this .bat file from the run command or by simply double-clicking on it and it works fine. From PRTG it will not.

Server is Windows 2008 R2 x64

PRTG version 8.1.2.1810

The batch file itself uses psexec to stop/restart a remote service on another server.

Does anyone have a solution or some suggestions? Thank you.

Created on Dec 30, 2010 9:09:41 PM

Last change on Jan 3, 2011 8:50:18 AM by  Daniel Zobel [Product Manager]



Votes:

0

Hi Ted,

Please check that the path to the batch file is correct from the point of view of the machine where the Launcher app is running on. Also check that the credentials provided with the -u= and -p= parameters have enough rights to launch the batch file. For testing purposes you could add a few pause commands to the batch file to see if it is launched at all and if all steps are executed.

Regards, Gerard

Created on Jan 3, 2011 9:32:16 AM



Votes:

0

Thanks for your reply. I'm still having trouble.

The Launcher app runs on the PRTG server. I inserted a pause in the batch file right before the PSexec program is called. Running the test notifcation from PRTG opens the batch file to the pause, then it simply closes after you type any key to continue. It will not run the PSexec command. If I double-click the batch file on the local PRTG desktop it runs fine.

I've tried the user and password from a domain admin account and the local machine admin account with Launcher - neither work, but both work running the batch file manually.

Any other ideas? Thanks!

Created on Jan 3, 2011 7:11:29 PM



Votes:

0

In the batch file have you provided the full path to the PSexec program?

Created on Jan 4, 2011 4:32:37 PM



Votes:

0

No, I have not. However, it still works by just running the batch file manually.

@echo off REM restarts Apache Tomcat Service psexec
xxx.xxx.xxx.xxx -u Domain\User -p Password net stop "Apache Tomcat" psexec
xxx.xxx.xxx.xxx -u Domain\User -p Password net start "Apache Tomcat"

I just really don't understand why the batch file works fine manually, but can't seem to be scheduled or run by PRTG or Launcher.

Created on Jan 4, 2011 7:01:51 PM



Votes:

0

Well, the batch file can be run by PRTG and Launcher as the previously pause command in your batch file worked !!

When the batch file is executed by Launcher, no working folder is set. In other words if you do not supply the full path to PSExec, the batch file will not be able to find it.

When you start the batch file from a cmd window, or by double clicking it, the working folder is set to the current folder and if PSExec resides there, the batch file will be able to find it.

You could also try a pause command after PSEXec for debugging purposes to see if any error like "file not found" is written to the command line.

@echo off
REM restarts Apache Tomcat Service
"c:\Program Files\PRTG Network Monitor\Custom Sensors\EXE\psexec" \\xxx.xxx.xxx.xxx -u Domain\User -p Password net stop "Apache Tomcat"
"c:\Program Files\PRTG Network Monitor\Custom Sensors\EXE\psexec" \\xxx.xxx.xxx.xxx -u Domain\User -p Password net start "Apache Tomcat"
pause

Created on Jan 5, 2011 8:02:17 AM



Votes:

0

Gerard,

Thanks for the information. This worked perfectly!

Ted

Created on Jan 7, 2011 4:44:23 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.