|
View previous topic :: View next topic |
Author |
Message |
spbhatnagar
Joined: 03 Jun 2015 Posts: 2
|
Posted: Thu Jun 04, 2015 12:11 am Post subject: VBS execution inconsistency between Application and service |
|
|
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 |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Thu Jun 04, 2015 6:50 am Post subject: |
|
|
First, I would recommend to specify full path to SendKeys1.vbs and, possibly, for ftp.exe, telnet.exe and cscript.exe. |
|
Back to top |
|
|
spbhatnagar
Joined: 03 Jun 2015 Posts: 2
|
Posted: Sun Jun 07, 2015 5:29 am Post subject: Path added |
|
|
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. |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Mon Jun 08, 2015 11:45 am Post subject: |
|
|
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: | 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}"
...
...
|
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|