Sunday, March 11, 2012

DTS package failing with Object required WScript

I have the following error when I try to execute a DTS package.
All the package is doing, is a bit of WScript to map a drive (need it for other packages), so:

[code]

Function Main()
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.RemoveNetworkDrive "S:"
WshNetwork.MapNetworkDrive "S:", "\\myserver\folder1\folder2\folder3\folder4"
Main = DTSTaskExecResult_Success
End Function

[/code]

If I copy it out to a .vbs file and execute it logged in as the SQL Agent profile, it works. Execute the package under a job, or just execute it, it fails with the above error.
Any ideas?

This is a SSIS forum, not DTS! Try microsoft.public.sqlserver.dts, you're more likely to get help there.

-Jamie

|||WScript object is specific to wscript.exe host application (that runs .VBS files), it is not part of VBScript language, so you can't use it in DTS scripts.
I think just CreateObject (without "wscript.") should work as well, but I don't know VBScript. You may try VBScript or DTS newsgroups to get better answer.|||

Sussed it. If I use:

Set WshNetwork = CreateObject("WScript.Network")

It works fine

No comments:

Post a Comment