Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Windows GenericSerivce attribute quesiton

Created: 24 Feb 2014 • Updated: 06 Mar 2014 | 17 comments
mokkan's picture
This issue has been solved. See solution.

Hello,

I need to run a script called  c:\app\app.vbs .  Can I use  GenericService as type? for servicename attribute, can I put c:\app\app.vbs .?  Would it work? Is this syntax correct?

Operating Systems:

Comments 17 CommentsJump to latest comment

Gaurav Sangamnerkar's picture

Hello,

Again, if you look at bundled agents guide you should have your answers.

GenericService can be used if Windows service residing in the Service Control Manager (SCM). In your case it is not & its a user defined script so you would need to use ServiceMonitor agent. Refer to ServiceMonitor agent details in Bundled agents guide

G

PS: If you are happy with the answer provided, please mark the post as solution. You can do so by clicking link "Mark as Solution" below the answer provided.
 

Marianne's picture

Process Agent is probably more appropriate.

PLEASE bookmark the Documentation page on SORT:

https://sort.symantec.com/documents 

There are separate manuals for Windows...

Supporting Storage Foundation and VCS on Unix and Windows as well as NetBackup on Unix and Windows
Handy NBU Links

SOLUTION
mikebounds's picture

I agree with Marianne - you need to use the Process Agent - this is more like the Application agent in UNIX as it has a StartProgram, StopProgram and MonitorProgram, than the Process agent in UNIX which does NOT have a StartProgram, StopProgram and MonitorProgram and so it is annoying that it is not called the Application agent in Windows.

Note your StartProgram will need to be "cscript.exe c:\app\app.vbs"

The Process agent in Windows, does have the capabilty to run like the Process agent in UNIX if the StartProgram is the name of the process that runs, so if "cscript.exe c:\app\app.vbs" runs continously and can be seen in the process table (tasklist) then you just need to specify StartProgram, but if, more likely, c:\app\app.vbs runs some commands and then exits, you will need to use MonitorProgram like in https://www-secure.symantec.com/connect/forums/how-setup-appplication-script-configuration-file

Mike

UK Symantec Consultant in VCS, GCO, SF, VVR, VxAT on Solaris, AIX, HP-ux, Linux & Windows

If this post has answered your question then please click on "Mark as solution" link below

SOLUTION
mokkan's picture

Thank you very much guys.

I can run it in command line and works fine. This script was written in visual basic. Is visual basic can retun 0? If it succceed.

 
2014/02/25 16:11:40 VCS ERROR V-16-10051-6532 Process:Power_VM_Process:online:Failed to launch the program 'C:\\Scripts\\Shutdown1.vbs'. Error = 2.
2014/02/25 16:13:40 VCS ERROR V-16-2-13066 Thread(7024) Agent is calling clean for resource(Power__VM_Process) because the resource is not up even after onl

Wally_Heim's picture

Hi Mokkan,

Error 2 is "The system cannot find the file specified".

   C:\>net helpmsg 2

   The system cannot find the file specified.

The thing to keep in mind is that HAD runs as the "System" account so the scripts that you are using need to have permissions to allow the "System" account to execute them.

It looks like your start program is defined as 'C:\\Scripts\\Shutdown1.vbs'.  The start program should be set to something like this "cscript.exe C:\\Scripts\\Shutdown1.vbs".  

You also mentioned that you are were able to run this script at a command prompt without issues.  That command prompt was opened as the logged in user and not the system account so that did not really check if HAD can run the script.

If the script that you provide exits and does not stay running all the time, then you need to have a monitor program and a stop program defined.  The monitor program would need to return 100 for the resource to be offline and 110 for the resource to reported as online.

The bundle agents guide and the Agent Developers guides are good resources that may help you with the development of this resource.

Thank you,

Wally Heim
 

mokkan's picture

Thank you very much. I tried as below and still getting the same error message/

I have configured as below in java console in startprogram.  Am I making any synatax error?

"cscript.exe C:\\Scripts\\Shutdown1.vbs"

Marianne's picture

Have you seen the section in Wally's post about permissions?

Have you tried to add attributes such as:
UserName
Password
Domain

?

Does the script actually start any process that can be monitored by VCS?
Probably not if script is called Shutdown1, right?

Have a look at BundledAgent Guide for StartProgram attribute:

The process to be monitored by the agent. You
must specify the complete path of the executable,
its file extension, and command-line arguments,
if any. If you define the start program as a batch
file or a script to launch another program, you
must specify the monitor program in the
configuration file.
If you define the start program as a script (a perl
script, or a vbs script), the start program should
be the program that interprets the script (perl.exe,
or cscript.exe) and the script itself should be
passed as an argument.
Note: This attribute can take localized values.
 
The above means that you need to specify a MonitorProgram.
Extract from the manual:
 
program that monitors the process
specified as the start program. You must
specify the complete path of the executable,
its file extension, and command-line
arguments, if any.
If you do not specify a value for this
attribute, VCS monitors the start program.
However, if the start program is a batch file
or a script to launch another program, you
must specify a monitor program.
The Process agent supports Intelligent
Monitoring Framework (IMF). However, IMF
is not supported for the MonitorProgram
attribute. If a script or a batch file is specified
for this attribute, the Process agent does not
use IMF notification to monitor the program.
The agent detects the faults only during the
regular monitor function.
This attribute can take localized values.
Note: The monitor program is spawned every
monitor cycle and must return before the
program specified in MonitorProgram times
out. The return values for the monitor
program must conform to VCS conventions:
110 for ONLINE and 100 for OFFLINE. For exit
values outside the range 100-110, the status
is considered UNKNOWN. Refer to the VCS
Agent Developer’s Guide for more
information.

Supporting Storage Foundation and VCS on Unix and Windows as well as NetBackup on Unix and Windows
Handy NBU Links

mokkan's picture

I am almost there. I don't want to show the password. Can I give encrypted password? If so, any steps I need to following in Windows?

Wally_Heim's picture

Hi Mokkan,

I did some testing.  It appears that the process agent for Windows has changed slightly.  It appears that it wants an extra set of \'s in the path that the older versions did not require.  Try adding adjusting your configuration so that the start program is like this in the main.cf:  "cscript.exe C:\\\\Scripts\\\\Shutdown1.vbs".  It worked in my lab to get me around the same issue.

I'm also attaching our sample process agent scripts and sample main.cf that I was testing with.  You can use it to test with or modify it to call your VBS script from within if you want.  Extract the zip file to c:\scripts folder on each server then configure the process resource the way the sample main.cf has it and it should work for you.

Thank you,

Wally

AttachmentSize
sampleprocess.zip 978 bytes
Wally_Heim's picture

Hi Mokkan,

We don't need the password. You can blank out that attribute if still you want to share your configuration.  But I think my last post will resolve your issue.

Thank you,

Wally

mokkan's picture

Thanks a loooooot.  I don't have stop script or monitor script. Is it mandortary to run start script?

Wally_Heim's picture

Hi Mokkan,

The stop and monitor scripts are only needed if your start program does not stay running full time after starting.

I have stop and monitor because my start program creates a file and exits.  So my stop and monitor programs are needed so that the agent can determine the state of the process and put it in a stopped state when it goes offline.

If your application stays running, then the process agent will get its PID on startup, check that it is running during a monitor and kill it during stop.

Thank you,

Wally

mokkan's picture

Hi Wally,

Thanks a lot for all the explanation. I'm new to Windows and this bat file.

In your start.bat file, you put

echo > c:\scripts\marker.id

How does VCS knows that echo command was run success fully? Doesn't it need to exit with 0? 

Or monitor agent  will check marker.id and if it exist, it would show as online after 30 seconts( if the interval is 30 secs)?

It may be a stupid question :)

Wally_Heim's picture

Hi Mokkan,

Widnows by default will exit with error code 0 if there were no errors in the batch file.  But VCS knows that the online completed successfully when the monitor.pl script runs and checks that the marker.id file exists.  The sonitor.pl script exits with 100 for offline, 110 for online and bascially any other return is unknown by VCS.

Thank you,

Wally Heim

mokkan's picture

Thanks a lot. I am almost there. Now, I am getting this error message. Is it becasue fo the scirpt issue?

Failed to launch the program 'c:\\scripts\\shutdown.vbs'. Error = 193. 

In the main.cf file. I am seeing \\\\ , but in error message only \\

Where is the windows error number doc? Sorry I am new to Windows .

Wally_Heim's picture

Hi Mokkan,

I use either "net helpmsg <number>" that is built into the OS or err.exe that is downloadable via Microsoft to decode windows error messages.

For 193, the "net helpmsg 193" output says that 193 is not a valid windows code for it to decode.

For err, this is what I get:

C:\>net helpmsg 193
193 is not a valid Windows network message number.

More help is available by typing NET HELPMSG 3871.

C:\>err 193
# for decimal 193 / hex 0xc1 :
  SPECIAL_POOL_DETECTED_MEMORY_CORRUPTION                       bugcodes.h
  SQL_193_severity_15                                           sql_err
# The object or column name starting with '%.*ls' is too
# long. The maximum length is %d characters.
  ERROR_BAD_EXE_FORMAT                                          winerror.h
# %1 is not a valid Win32 application.
# for hex 0x193 / decimal 403 :
  SQL_403_severity_16                                           sql_err
# Invalid operator for data type. Operator equals %ls, type
# equals %ls.
  HTTP_STATUS_FORBIDDEN                                         winhttp.h
# request forbidden
# 5 matches found for "193"

C:\>

From experience, I woudl focus on the "ERROR_BAD_EXE_FORMAT" message as being the one that you are getting. VCS does not see VBS scripts as valid executables that it can run directly.  This was why we were recommending that you try running vbs script by passing it to the cscript.exe or maybe to cmd.exe.  Or you could call it from a batch file that VCS will execute.

The GUI will only show the '\\" but the main.cf will have "\\\\".  Its a coding issue with the format that the main.cf is stored in.  Basically, when a "\" is seen in the main.cf the next charactor is a special or control charactor.  So when you see something like, "\n" in the main.cf it means "New Line",  For the format to translate a single "\" it puts in "\\".  The first one says that the next charactor is a control charactor and the second one in this case says to display a single "\".  Its confusing coding stuff.  I've reported the need for doubling the "\" as an issue to our Engineering team so that they can fix this in a future release.

Thank you,

Wally Heim

SOLUTION
mokkan's picture

THANK  YOU VERY MUCH ALL OF YOU. IT WORKED!!!