dbTalk Databases Forums  

Running Shell Function in ActiveX task

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


Discuss Running Shell Function in ActiveX task in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gerald Hopkins
 
Posts: n/a

Default Running Shell Function in ActiveX task - 05-20-2004 , 04:17 AM






Allan (or anyone else who knows the answer), I found this excerpt from a
post you answered a couple of years ago that addresses my need to run
the Shell function inside an ActiveX task. However, my VBScript code
does not seem to recognize the object 'WScript'. I am not using a VB
Project. I am using the DTS interface to create a package that has an
ActiveX task in which I want to run the Shell funtion to execute a file.
The filename will be built dynamically. So, the Execute Process Task
won't do.

How do I add the Windows Script Host libray to my "project" that is not
really a Project so that the ActiveX VBScript will recognize it?


Thanks,

Gerald

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

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

Default Re: Running Shell Function in ActiveX task - 05-20-2004 , 05:45 AM






WScript is Windows Scripting Host or Microsoft Windows Script. You may not
have the libraries installed, so have a look here to get more info and
install set-

Downloads
(http://msdn.microsoft.com/library/de...list/webdev.as
p)


You can still use the Execute Process Task, as you can use script to change
the task itself -

How to manipulate the Execute Process task.
(http://www.sqldts.com/default.aspx?251)

--
Darren Green
http://www.sqldts.com

"Gerald Hopkins" <ghopkinsjr (AT) aol (DOT) com> wrote

Quote:
Allan (or anyone else who knows the answer), I found this excerpt from a
post you answered a couple of years ago that addresses my need to run
the Shell function inside an ActiveX task. However, my VBScript code
does not seem to recognize the object 'WScript'. I am not using a VB
Project. I am using the DTS interface to create a package that has an
ActiveX task in which I want to run the Shell funtion to execute a file.
The filename will be built dynamically. So, the Execute Process Task
won't do.

How do I add the Windows Script Host libray to my "project" that is not
really a Project so that the ActiveX VBScript will recognize it?


Thanks,

Gerald

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



Reply With Quote
  #3  
Old   
Gerald Hopkins
 
Posts: n/a

Default Re: Running Shell Function in ActiveX task - 05-20-2004 , 01:38 PM



Darren, thanks for the quick response.

I looked at both of your suggestions. I'd like to get the WScript option
to work since I have developed down that avenue already; although, I had
thought about controlling the Execute Process task, I just didn't know
how to do it. Thanks for reading my mind and giving me that option as
well.

On my machine, I have the Windows Script Host Object Model installed in
C:\WINNT\system32\wshom.ocx because I can see it in the object browser
in Visual Studio VB6. I'm not sure why the DTS ActiveX Task Properties
window won't recognize it when I choose VBScript as the Language. Maybe
there is a different DLL for the VBScript version?? I'll go ahead and
download the Windows Script 5.6 for Windows 2000 anyway to see.

Thanks,

Gerald

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

Reply With Quote
  #4  
Old   
Gerald Hopkins
 
Posts: n/a

Default Re: Running Shell Function in ActiveX task - 05-20-2004 , 05:57 PM



Darren, I installed the WSH package as you suggested and, at first, the
code still erred. As I was writing another response to report that, I
noticed that I hadn't posted the code snippet that I was running. When I
took a closer look at it, I noticed something funny about it and
corrected it. When I did, it ran fine. Also, when I looked at the old
post and replies again, I noticed that it wasn't Allan's code snippet at
all but was from someone else and was sandwiched between a couple of
Allan's replies in a long conversation! My apologies to both of you and
thanks for your help. You guys are great!

FYI, the code snippet I WAS using is this:

Set WshShell = WScript.CreateObject("WScript.Shell")
Command = "%WINDIR%\Calc.exe"
WshShell.Run Command


As you can probably see, there shouldn't be a WScript qualifying object
before the CreateObject method. When I removed it, the code ran fine.

Thanks,

Gerald

*** 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.