dbTalk Databases Forums  

VBScript Task errors on WScript.Sleep

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss VBScript Task errors on WScript.Sleep in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Fly Girl
 
Posts: n/a

Default VBScript Task errors on WScript.Sleep - 11-17-2003 , 12:07 PM






Windows 2K and SQL Server 2K

When I run the following code I get an error: "An
exception of type 'Microsoft (sic) VBScript runtime error:
Object required: 'WScript" (sic) was not handled."

I have downloaded the most recent wsh script update (5.6).

'************************************************* *********
' Visual Basic ActiveX Script
'************************************************* *********

Function Main()

Dim WshShell
Dim intFiles
Dim intReturn
Dim objExec

intFiles = DTSGlobalVariables("intCount")

If intFiles <> 0 then

Set WshShell = CreateObject("WScript.Shell")

Set objExec = WshShell.Exec("c:\averypdf\img2pdf.exe -
b -1 -o c:\1pdf\*.pdf c:\1working\*.tif'")

Do While objExec.Status = 0
WScript.Sleep 100
Loop

WScript.Echo objExec.Status

Set objExec = Nothing
Set WshShell = Nothing

Main = DTSTaskExecResult_Success

End Function

************************************************** *********

The code errors on the line for WScript.Sleep.

Any suggestions? I need to have the script task wait until
I the executable has run and finished it's process.

Thanks!


Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: VBScript Task errors on WScript.Sleep - 11-17-2003 , 01:08 PM






In article <000901c3ad35$b5948fb0$a501280a (AT) phx (DOT) gbl>, Fly Girl
<gschipper (AT) rgl (DOT) net> writes
Quote:
Windows 2K and SQL Server 2K

When I run the following code I get an error: "An
exception of type 'Microsoft (sic) VBScript runtime error:
Object required: 'WScript" (sic) was not handled."

<snip>
Quote:
The code errors on the line for WScript.Sleep.

Any suggestions? I need to have the script task wait until
I the executable has run and finished it's process.

Thanks!

WScript is an implicit object available in the WSH host. You are not
running under WSH, although you are using the same language. Your host
is the DTS ActiveX Script host, which does not the WScript object, it
offers things like DTSGlobalVariables instead.

One downside of this is that Sleep is not exposed as an object method on
something that you can create, so you cannot call it in an DTS ActiveX
Script.

The Echo can be replaces with the MsgBox function or statement.

You could try the Run method instead as this has the bWaitOnReturn
parameter, but it not quite the same as Exec.


Or

Use the Execute Process Task to call the program. This waits for you.

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #3  
Old   
Gail Schipper
 
Posts: n/a

Default Re: VBScript Task errors on WScript.Sleep - 11-17-2003 , 01:42 PM



Thanks very much for the explanation and ideas. It's always nice to know
why something is blowing up on you.

I have implemented this using:

WshShell.Run ("c:\averypdf\img2pdf.exe -b -1 -o c:\1pdf\*.pdf
c:\1working\*.tif", , True)

And what do you know? It works!

I will also take a look at Execute Process Task just for kicks since I
am not familiar with that method.

Kudos and thanks!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.