 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
JLEZAMA
Joined: 14 Jul 2008 Posts: 4 Country: Honduras |
|
RUN VBS FILE in 24x7 multi platform |
|
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 |
|
 |
JLEZAMA
Joined: 14 Jul 2008 Posts: 4 Country: Honduras |
|
|
|
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7949
|
|
|
|
 |
 |
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 |
|
 |
JLEZAMA
Joined: 14 Jul 2008 Posts: 4 Country: Honduras |
|
|
|
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7949
|
|
|
|
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 |
|
 |
|
|
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
|
|
|