SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
using wscript object in vbscript jobs

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
using wscript object in vbscript jobs
Author Message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post using wscript object in vbscript jobs Reply with quote

I am trying to use methods of the WScript object, e.g. wscript.sleep and wscript.quit, in a VBScript job. These lines error out with:
Processing Error #21
VBScript Error #424
Error message: Object required: 'wscript'

The wscript object is instantiated automatically when a vbs is run by wscript.exe and cscript.exe. How do I access methods of the WScript object in a 24x7 job?

Also, I was hoping to use wscript.quit to return an error code whenever I want 24x7 to flag the job as failed. Am I on the right track here?

Thank you,
Greg

Tue May 28, 2002 5:07 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: using wscript object in vbscript jobs Reply with quote

You can create it explicitly using CreateObject

: I am trying to use methods of the WScript object, e.g. wscript.sleep and
: wscript.quit, in a VBScript job. These lines error out with: Processing
: Error #21
: VBScript Error #424
: Error message: Object required: 'wscript'

: The wscript object is instantiated automatically when a vbs is run by
: wscript.exe and cscript.exe. How do I access methods of the WScript object
: in a 24x7 job?

: Also, I was hoping to use wscript.quit to return an error code whenever I
: want 24x7 to flag the job as failed. Am I on the right track here?

: Thank you,
: Greg

Tue May 28, 2002 8:25 pm View user's profile Send private message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post Re: using wscript object in vbscript jobs Reply with quote

How do I create it explicitly? I have tried the following:

Set objWScript = CreateObject("WScript")

But that gives me VBScript Error #429, Error message: ActiveX component can't create object: 'WScript'.

Thank you.

: You can create it explicitly using CreateObject

Tue May 28, 2002 10:31 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: using wscript object in vbscript jobs Reply with quote

Try CreateObject("WScript.Network") or CreateObject("WScript.Shell")
whatever you need.

For the sleep you can also use
JALScript.Execute("Wait 10") replace wait with the number of seconds you want to "sleep"

: How do I create it explicitly? I have tried the following: Set objWScript =
: CreateObject("WScript")

: But that gives me VBScript Error #429, Error message: ActiveX component can't
: create object: 'WScript'.

: Thank you.

Wed May 29, 2002 8:25 am View user's profile Send private message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post Re: using wscript object in vbscript jobs Reply with quote

Yes, I have been using child objects of the WScript root object without problem. I guess what you are telling me is that methods and properties of the WScript root object is inaccessible from within a 24x7 vbscript job.

Thank you for the alternative "sleep" method using JALScript.Execute.

The other issue I had was returning an exit code to 24x7 from my vbscript job. I was trying to use wscript.quit to effect this. Is there another way for a vbscript job to return a "failure" exit code so that 24x7 will flag the job as "failed"?

Thanks for the good help!

: Try CreateObject("WScript.Network") or
: CreateObject("WScript.Shell")
: whatever you need.

: For the sleep you can also use
: JALScript.Execute("Wait 10") replace wait with the number of
: seconds you want to "sleep"

Wed May 29, 2002 10:03 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: using wscript object in vbscript jobs Reply with quote

I guess I am missing something. Do you run VBScript as a document file (program type job) outside of 24x7 or you run it as a VBScript job inside 24x7?

If you run it inside, you cannot use wscript.quit as there is no wscript. If your "inside" code fails for whatever reason it is automatically detected by 24x7 and the job fails unless you have checked "ignore errors" job option or suppressed errors within your code using On Error Resume Next or similar.

: Yes, I have been using child objects of the WScript root object without
: problem. I guess what you are telling me is that methods and properties of
: the WScript root object is inaccessible from within a 24x7 vbscript job.

: Thank you for the alternative "sleep" method using
: JALScript.Execute.

: The other issue I had was returning an exit code to 24x7 from my vbscript
: job. I was trying to use wscript.quit to effect this. Is there another way
: for a vbscript job to return a "failure" exit code so that 24x7
: will flag the job as "failed"?

: Thanks for the good help!

Wed May 29, 2002 10:49 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: using wscript object in vbscript jobs Reply with quote

I forgot to say that WScript is not an object, it is a program that runs the MS script control. WScript is "Microsoft (r) Windows Based Script Host". Methods like sleep and quit are extensions of that particular program.

Of cource you can run external VBScripts using that progtam and program type jobs. In program type and JALScript type jobs you can capture the process exit code and put some logic into main script or notification action to handle the returned code.

The only issue with "outside" job definitions is that you have to deploy and replicate them yourself if you run remote jobs or do some job replication. 24x7 takes complete care of "inside" job definitions.

: Yes, I have been using child objects of the WScript root object without
: problem. I guess what you are telling me is that methods and properties of
: the WScript root object is inaccessible from within a 24x7 vbscript job.

: Thank you for the alternative "sleep" method using
: JALScript.Execute.

: The other issue I had was returning an exit code to 24x7 from my vbscript
: job. I was trying to use wscript.quit to effect this. Is there another way
: for a vbscript job to return a "failure" exit code so that 24x7
: will flag the job as "failed"?

: Thanks for the good help!

Wed May 29, 2002 10:57 am View user's profile Send private message
Greg Morris



Joined: 24 May 2002
Posts: 26

Post Re: using wscript object in vbscript jobs Reply with quote

I'm sure it's me missing something, and I appreciate the help in figuring out what it is. :-) I am running as a VBScript job inside 24x7. I am handling my errors using "On Error Resume Next" in order to code in retry logic for some error conditions and to ignore acceptable error conditions. Yet when I have a catastrophic error condition, I want the job to fail.

Maybe, instead of "wscript.quit ", I can disable error handling and then do an "Err.RaiseError " whenever I have a catastrophic condition. I'll try that and see if that gives me the desired result.

Again, thank you for your time!

: I guess I am missing something. Do you run VBScript as a document file
: (program type job) outside of 24x7 or you run it as a VBScript job inside
: 24x7?

: If you run it inside, you cannot use wscript.quit as there is no wscript. If
: your "inside" code fails for whatever reason it is automatically
: detected by 24x7 and the job fails unless you have checked "ignore
: errors" job option or suppressed errors within your code using On
: Error Resume Next or similar.

Wed May 29, 2002 11:37 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
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
Design by Freestyle XL / Flowers Online.