VBS execution inconsistency between Application and service

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
spbhatnagar
Posts: 2
Joined: Wed Jun 03, 2015 11:54 pm

VBS execution inconsistency between Application and service

Post by spbhatnagar »

Hi Guys,

I have recently installed Hostmon version 9.90 to monitor a device and execute certain batch files in windows shell using VBS to change configuration in the event of device failure.

I am using a windows 2003 standard R2 server and have noticed that the vbs script (called through a windows command shell via external program option) only works if HMon is running as a stand-alone application and not as a windows service. Have tried changing user credentials to admin but it hasnt helped.

I do not have any prior knowledge of scripting, so would like to make minimal changes to the script below:

Basic flow:
1. when device fails Hostmon generates a trap and runs a windows batch file which runs the command : telnet 192.168.x.x and then runs a VBS file..details below:

ftp -A -i -s:ftp.txt 192.168.161.6
sleep 20
:: Open a Telnet window
start telnet.exe 192.168.161.5
:: Run the script
cscript SendKeys1.vbs


2. I noticed that the vbs script only passes values when HS runs as an application..Script sendKeys1.vbs below:

set OBJECT=WScript.CreateObject("WScript.Shell")
WScript.sleep 5050
OBJECT.SendKeys "y{ENTER}"
WScript.sleep 3050
OBJECT.SendKeys "administrator{ENTER}"
WScript.sleep 2050
OBJECT.SendKeys "nmxxxxxxx{ENTER}"
WScript.sleep 2000
OBJECT.SendKeys " net stop ""mgxxxx"" {ENTER}"
WScript.sleep 2050
OBJECT.SendKeys " netsh interface ip set address name=""xx"" static 192.168.15.7 255.255.255.0 {ENTER}"
WScript.sleep 5050
OBJECT.SendKeys " netsh interface ip set address name=""xxxx"" static 192.168.161.7 255.255.255.0 192.168.161.254 1 {ENTER}"
WScript.sleep 5050
OBJECT.SendKeys " exit{ENTER}"
WScript.sleep 50
OBJECT.SendKeys " "


3. similar scripts are used to telnet and change ip addresses in multiple other devices.



Could you please verify whether this is an issue because I am executing a run command instead of exec in vb script? What changes would you recommend?

Regards,
Sid
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

First, I would recommend to specify full path to SendKeys1.vbs and, possibly, for ftp.exe, telnet.exe and cscript.exe.
spbhatnagar
Posts: 2
Joined: Wed Jun 03, 2015 11:54 pm

Path added

Post by spbhatnagar »

The path has been added to the script. Although i didnt suspect that was the issue since the ftp and telnet were working...It still doesnt work...

Can you run a sample cscript through a batch file in your lab using hostmonitor to see if the vbs script can display text in a windows command prompt/notepad.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Yes, this will not work in Service mode.
However, if you'll start telnet inside VB script, telnet commands will be executed from HostMontor, running as Service.
Try the following:
1. Remove/comment the following line in your .BAT file:
start telnet.exe 192.168.161.5
2. Modify your VB script the following way (start telnet from VB script):

Code: Select all

set OBJECT=WScript.CreateObject("WScript.Shell")
OBJECT.run "cmd.exe"
WScript.sleep 1050
OBJECT.SendKeys "telnet.exe 192.168.161.5{ENTER}"
WScript.sleep 5050
OBJECT.SendKeys "y{ENTER}"
WScript.sleep 3050
OBJECT.SendKeys "administrator{ENTER}"
WScript.sleep 2050
OBJECT.SendKeys "nmxxxxxxx{ENTER}"
...
...
Post Reply