Cannot start batch script

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
CountiesPowerAdmin
Posts: 19
Joined: Sun Sep 19, 2010 5:52 pm

Cannot start batch script

Post by CountiesPowerAdmin »

I have a batch script that I cannot run from Hostmon.

The purpose of the script is to start Windows SMS Sender and send a message to my mobile via the mobile that is connected to the Hostmon server.

When I run the script from the command line it performs perfectly.

Within Hostmon I have created an Action Profile called AlertSteve. This Action Profile has two Actions, an email and a text. The email Action works fine. The text Action, called TextSteve, does not work. I have configured it with the following settings:

Action type: Execute External Program
Action name: SteveText
Execute by: HostMonitor
Condition to Start Action: standard mode
Start When: 1 consecutive Bad results occur
Repeat: Until status changes
Time Restriction: None
Command Line: cmd /c "C:\Program Files\HostMonitor8\Text.bat" 0275993536 KS_PRINTER PING BAD
Window Mode: SW_SHOWNORMAL

If I copy and paste the contents of Command Line into a Run... it works perfectly.

However when I test this action profile nothing happens.

The contents of the batch script are as follows:
@echo off
start "SENDTEXT" "C:\Program Files (x86)\Microsoft SMS Sender\SMSSender.exe" /p:%1 /m:"%2 is testing %4 for the following test: %3"
ping -n 8 -w 10000 127.0.0.1
taskkill /im SMSSender.exe
exit


Can anyone help? :(

Thanks in advance.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

This Action Profile has two Actions, an email and a text. The email Action works fine. The text Action, called TextSteve, does not work
There is no "text" action. I assume you are talking about "Execute external program" action?

HostMonitor should record error description into log when it cannot perform some action.
Have you checked HostMonitor system log file (specified on System Log page in the Options dialog) or Quick Log for actions? Any errors?

What version of HostMonitor do you use?
Windows?
Service Pack?
HostMonitor started as service or application?

Regards
Alex
CountiesPowerAdmin
Posts: 19
Joined: Sun Sep 19, 2010 5:52 pm

Post by CountiesPowerAdmin »

It runs an External Application (see the Action type in my previous post).

Details are as follows:
Version of Hostmon:8.82
Windows:2008 Server R2
Service Pack: None installed
Hostmon started as: Service

The log is stating the following:

Error: cannot execute command "cmd /c "C:\Program Files\HostMonitor8\Text.bat" 0275993536 KS_PRINTER PING BAD". A required privilege is not held by the client.

Which "client" is this? Is this the client mentioned in the Execute by field of the action or is it the Hostmon under the Service menu in Options or is this something else?

Again, thanks in advance.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

If action is executed by HostMonitor then "client" is HostMonitor.
If HostMonitor is started as service then yes, you should check account you have specified on Service page in HostMonitor options dialog.
May be you are using account that belongs to domain admins group but does not belong to local admins...

Regards
Alex
CountiesPowerAdmin
Posts: 19
Joined: Sun Sep 19, 2010 5:52 pm

Post by CountiesPowerAdmin »

We have checked the Hostmon account. It has fully administrative access, both locally and on the domian. The password and access rights have all been checked.

I have been thinking about what could be causing this issue and I was thinking that perhaps:

1) Maybe the script needs to be run in compatibility mode of some sort? - we have unsuccessfully tried XP but to no avail.

2) The cmd command line can be configured to include admin credentials?

3) Folder permissions are preventing it from working? - again we have tried this but to no avail.

I'm just thinking out loud. :-?

Is there anything you can think of that we should check or might have overlooking?
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

We have checked the Hostmon account. It has fully administrative access, both locally and on the domian
Does "Replace process level token" policy allowed for this account?
1) Maybe the script needs to be run in compatibility mode of some sort? - we have unsuccessfully tried XP but to no avail.
No, its not compatibility related problem. Its permission related problem.
2) The cmd command line can be configured to include admin credentials?
Text in command line are just parameters for child process. If such process cannot be started, parameters do not make any difference.

How exactly have you setup HostMonitor? Service itself started under local system account while account with local admin rights specified on Service page in HostMonitor Options dialog?
Do you see message like "Logged on as user nnn" in HostMonitor system log?
Or may be there is message like "Cannot logon as user nnn"?

Regards
Alex
CountiesPowerAdmin
Posts: 19
Joined: Sun Sep 19, 2010 5:52 pm

Post by CountiesPowerAdmin »

We have changed how we set up Hostmon and the services. It is currently as follows,

Hostmon services have been set up as a local system account. There are two services running:

KS Web Service
KS Advanced Host Monitor

Under the Service page in Hostmonitor Options dialog we have an admin account called hostmon. It has both domain and local rights.

I have not seen "Logged on as user <name>" or "Cannot logon as user <name>" anywhere in the system log.

Since we have made this change the "A required privilege is not held by the client." has disappeared. When we test the running of the batch script a message stating there are compatibility issues with Windows SMS Sender and Windows 2008 server pops up. This leads me to believe that the batch script IS running.

HOWEVER

If I change the account in the Hostmonitor Options dialog from Hostmon to my personal admin account, the same thing happens (I still get the message complaining about compatibility) but I DO recieve a text (we have set SMS Sender to run in compatibilty mode for all users).

This leads me to believe that our Hostmon setup is on the right track but that we still have permissions issues.

I have just spoken top our domain admin guy and he is going to see about enabling "Replace process level token" for the hostmon account. We will see how this goes and post the results, however any advice or thoughts you have in the meantime would be appreciated.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

If HostMonitor starts process but 3rd party application complains about compatibility issues while this application works fine under your account, probably this has nothing to do with permissions?
May be this application requires some "compatibility" settings that you setup under you personal account. When you start application using different account, it does not retrieve these settings (e.g. settings stored in the registry under HKEY_CURRENT_USER).

I think you should setup this application without using HostMonitor but using the same account you are using for HostMonitor. When application will work properly, setup HostMonitor.
I have not seen "Logged on as user <name>" or "Cannot logon as user <name>" anywhere in the system log
Have you checked HostMonitor system log (specified on System Log page in HostMonitor Options diaog)?

Regards
Alex
CountiesPowerAdmin
Posts: 19
Joined: Sun Sep 19, 2010 5:52 pm

Post by CountiesPowerAdmin »

Hi Alex,

Success!

We enabled the "Replace process level token" policy for the hostmon account.

To start with it was working, but only when hostmon was logged in.

We then adjusted the services to to run using the hostmon domain account rather than the local account.

This succeeded in getting the SMS messages to go through.

I've spent the afternoon messing with batch scripts so that the Hostmon variables will get passed through but I have managed to get it sorted in the end.

Thank you very much for your invaluable help. :)
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

No problem :)

Regards
Alex
Post Reply