Analysis of your IT infrastructure

Home Downloads Entrerprise Contact
supervision Cloud

Easy monitoring solution

Innovative application supervision by mapping.

Application monitoring

Application monitoring

Quickly access the status of all your applications from your PC, tablet.

freeware for monitoring

Azure & Power BI portal services

Native integration into Microsoft reporting solutions.





Using scripts with Monitorpack

Monitorpack allows you to call a file to respond to an alarm and trigger a procedure. In all cases Monitorpack only calls batch files. We recommend using by default batch files, or to call your vbs files, PowerShell, etc... from a bacth file.

The scripts subfolder of the Monitorpack Guard folder has limited access rights, by default you cannot not create files. We recommend that you run the scripts from this folder but generate the outputs of your queries in a folder where you have full rights to write, delete and modify.

Remember that this is the service account used by Monitorpack and which will actually run your scripts it is therefore to this account that you must give the rights.

Elevation of execution rights is something to consider when using PowerShell files refer to Microsoft TechNet for more information.



@echo off
powershell.exe -ExecutionPolicy Bypass -File "C:\Program Files (x86)\Monitorpack Guard\Scripts\MyScript.ps1"


@echo off
wscript.exe "C:\Program Files (x86)\Monitorpack Guard\monscript.vbs"


This script is only valid in a workgroup context because in this case it is necessary to have the same account service with the same password on all machines, So do not use this script in an Active Directory forest since it is enough to create the account once at the Active Directory forest level

' Name of the script : CreateMonitorpackAdminUsers.vbs
'Checks if the script is run with administrative privileges
If Not WScript.Arguments.Named.Exists("elevated") Then
' Crée un objet shell pour relancer le script en mode administrateur
Set objShell = CreateObject("Shell.Application")
' Relance le script avec les privilèges administratifs
objShell.ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /elevated", "", "runas", 1
WScript.Quit
End If
' Variables for new user accounts
Dim users(1)
users(0) = Array("sys_monitorsvc", "MotDePasseSecuriseSvc123!", "System Monitor Service")
users(1) = Array("sys_monitoradm", "MotDePasseSecuriseAdm123!", "System Monitor Admin")
' Create an object to manage users
Set objNetwork = CreateObject("WScript.Network")
Set objUser = GetObject("WinNT://" & objNetwork.ComputerName & "")
Set objGroup = GetObject("WinNT://" & objNetwork.ComputerName & "/Administrateurs,group")
' Function to create a user and add it to the Administrators group
Sub CreateAndAddUser(userName, password, fullName)
'Create the user account
Set objNewUser = objUser.Create("user", userName)
objNewUser.SetPassword password
objNewUser.FullName = fullName
objNewUser.SetInfo
' Adds the new user to the Administrators group
objGroup.Add(objNewUser.ADsPath)
End Sub
' Loop to create users and add them to the group
For Each user In users
CreateAndAddUser user(0), user(1), user(2)
Next
' Displays a confirmation message
WScript.Echo "Accounts sys_monitorsvc and sys_monitoradm have been created and added in Administrateurs group."


Run this script on all target machines you want to control. For your information, service WinRM is not required but can be useful if you are running Remote PowerShell scripts.

'Copyrigth Monitorpack 2003 -2023
' Name of the script : VerifyWindowsServicesForMonitorpack.vbs
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
'=================================================
' Verify if service WMI is Running
'=================================================
Set colItemsWMI = objWMIService.ExecQuery("Select * from Win32_Service Where Name = 'winmgmt'")
'=================================================
' Verify if service Remote Registry is Running
'=================================================
Set colItemsRemoteRegistry = objWMIService.ExecQuery("Select * from Win32_Service Where Name = 'RemoteRegistry'")
'=================================================
' Verify if service Remote RPC is Running
'=================================================
Set colItemsRemoteRPC = objWMIService.ExecQuery("Select * from Win32_Service Where Name = 'RpcSs'")
'=================================================
' Verify if service Remote DcomLaunch is Running
'=================================================
Set colItemsDcomLaunch = objWMIService.ExecQuery("Select * from Win32_Service Where Name = 'DcomLaunch'")
'=================================================
' Verify if service Remote RPC is Running
'=================================================
Set colItemsRemoteRPC = objWMIService.ExecQuery("Select * from Win32_Service Where Name = 'RpcSs'")
'Browses query results for WMI service
For Each objItem in colItemsWMI
If objItem.State = "Running" Then
' Service WMI is Running
MsgBox "Service WMI is Running.", vbInformation, "Service WMI"
Else
' Service WMI is Stopped
' ervice WMI is Stopped
MsgBox "ervice WMI is Stopped.", vbExclamation, "Service WMI"
End If
Next
' Browses query results for the Remote Registry service
For Each objItem in colItemsRemoteRegistry
If objItem.State = "Running" Then
' Service Remote Registry is Running
MsgBox "Service Remote Registry is Running.", vbInformation, "Service Remote Registry"
Else
' Service Remote Registry is Stopped
MsgBox "Service Remote Registry is Stopped.", vbExclamation, "Service Remote Registry"
End If
Next
' Browses query results for the Remote RPC service
For Each objItem in colItemsRemoteRPC
If objItem.State = "Running" Then
' Service Remote RPC is Running
MsgBox "Le service Remote RPC is Running.", vbInformation, "Service Remote RPC"
Else
' Le service Remote RPC is Stopped
MsgBox "Service Remote RPC is Stopped.", vbExclamation, "Service Remote RPC"
End If
Next
' Browses query results for the DcomLaunch service
For Each objItem in colItemsDcomLaunch
If objItem.State = "Running" Then
' Le service DcomLaunch is Running
MsgBox "Le service DcomLaunch is Running.", vbInformation, "Service DcomLaunch"
Else
' Service DcomLaunch is Stopped
MsgBox "Le service DcomLaunch is Stopped.", vbExclamation, "Service DcomLaunch"
End If
Next
' Verify if service WinRM (Windows Remote Management) is Running
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItemsWinRM = objWMIService.ExecQuery("Select * from Win32_Service Where Name = 'WinRM'")
' Browses query results for the WinRM service
For Each objItem in colItemsWinRM
If objItem.State = "Running" Then
' Service WinRM is Running
MsgBox "Le service WinRM is Running.", vbInformation, "Service WinRM"
Else
' Service WinRM is Stopped
MsgBox "Service WinRM is Stopped.", vbExclamation, "Service WinRM"
End If
Next


To restart or start a Windows service from a remote machine using a script, while taking into account security constraints, PsExec is a robust and secure.

PsExec is a utility from Microsoft's Sysinternals suite that allows you to execute processes remotely.
Make sure the service account you are using has the necessary permissions to run remote controls. You can add this account to the local administrators of each remote machine.

Download PsExec from the official website, unzip the file and place psexec.exe in a directory accessible via the PATH environment variable or in the same directory as your batch script.

Replace RemoteMachineName and ServiceName with the appropriate values. Save the file with a .bat extension (for example, manage_service.bat). Create a script-type Monitorpack alert and select the bath file to execute in the event of an alarm.

Start a Windows service:

@echo off
set ComputerName=RemoteMachineName
set ServiceName=ServiceName
psexec \\%ComputerName% -s -d sc start %ServiceName%

Stop and restart a Windows service:

@echo off
set ComputerName=RemoteMachineName
set ServiceName=ServiceName
psexec \\%ComputerName% -s -d sc stop %ServiceName%
psexec \\%ComputerName% -s -d sc start %ServiceName%