SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
RUN VBS FILE in 24x7 multi platform

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
RUN VBS FILE in 24x7 multi platform
Author Message
JLEZAMA



Joined: 14 Jul 2008
Posts: 4
Country: Honduras

Post RUN VBS FILE in 24x7 multi platform Reply with quote
HI ALL

Well I have a little problem with my 24x7 multiplatform edition, when I try to to run a vbscript with a wscript.sleep command the task return an error, supposedly the variable WScript is undefined, but t the WScript object it never needs to be instantiated before invoking its properties and methods, and its always available from any scrip file.

What I'm traying to do is open a Excel file an execute a macro, it opens the excel file but when the command wscript.sleep appears the task brokes down.

When I run the VBS file by it self it works perfectly.

I really dont know what to do with this and hope you can help me out.


Julian
From
Honduras



Mon Jul 14, 2008 11:11 am View user's profile Send private message
JLEZAMA



Joined: 14 Jul 2008
Posts: 4
Country: Honduras

Post Reply with quote
THIS IS THE CODE THAT I'M USING

Option Explicit
Dim objShell, strSheet, Racey, intCount
Dim strComputer, strOU, intRow
Dim objExcel, objSpread


Set objShell = CreateObject("WScript.Shell")
objShell.Run "Excel"
Wscript.Sleep 2000


objShell.SendKeys "{ENTER}"

Wscript.Sleep 1000


objShell.SendKeys "^j"

Wscript.Sleep 18000


objShell.SendKeys "%{F4}"
Mon Jul 14, 2008 11:20 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
Quote:
WScript object it never needs to be instantiated
this is not the case.

WScript is not a built-in feature of VBScript. It is part of the shell. When you run script file from the command line, the shell is loaded by cmd.exe to run your VBScript code. When you just run VBScript code from any other place, the shell is not available, and if you need it, you must instantiate it yourself. See http://msdn.microsoft.com/en-us/library/t0aew7h6.aspx and specifically http://msdn.microsoft.com/en-us/library/6t81adfd(VS.85).aspx for more info.

The VBScript jobs you run in 24x7 are internal script jobs (meaning they are encrypted, protected, debuggable, and both locally and remotely deployable). If you want to run them as external files, save them as files with .VBS extensions and then schedule command line jobs like cscript myscript.vbs.
Mon Jul 14, 2008 12:22 pm View user's profile Send private message
JLEZAMA



Joined: 14 Jul 2008
Posts: 4
Country: Honduras

Post Reply with quote
OK

I understand, I also tried to run the .vbs file like external file from the command line but didnt work, when i run it just excel opens but next the task disable it self and 193 error appears.

Maybe you could give me a code that works. I also tried to run the code from http://msdn.microsoft.com/en-us/library/6t81adfd.aspx but t didnt work either

thanks
Mon Jul 14, 2008 1:34 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7949

Post Reply with quote
24x7 provides a number of job management and process management extensions specifically designed for use in VBScript jobs, including RunAndWait, Pause, QueueJob, KillProcess and a number of others. The best way to see them and properly code is to use the "Paste VBSCript" function in the editor. Open up job script in 24x7 editor, click Edit menu then click Paste VBScript command, expand the required group of functions and pick the function you want. You can then have the required parameters filled in place or you can paste first and replace pasted parameter placeholders.

Hope this helps.
Mon Jul 14, 2008 2:00 pm 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.