Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 DTS VBScript

Author  Topic 

lawash44
Starting Member

5 Posts

Posted - 2006-10-04 : 08:52:00
On SQL SERVER 2000 ActiveX script task in VBScript

Why this script returns a runtime error

Function Main()
Dim ObjShell
Dim IntReturn

Set objShell = CreateObject("Wscript.Shell")
IntReturn = objShell.Run("c:\program files\microsoft office\office11\Excel.exe", 1, TRUE)

Main = DTSTaskExecResult_Success
End Function

Excel is located at this folder

Thanks

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2006-10-04 : 09:02:59
Ok, I'm confused...why would one want to run excel from a vbscript??

What is the error message?

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

lawash44
Starting Member

5 Posts

Posted - 2006-10-04 : 09:16:26
My final script will be :
'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

Function Main()
Dim ObjShell
Dim IntReturn

Set objShell = CreateObject("Wscript.Shell")
IntReturn = objShell.Run("c:\program files\microsoft office\office11\Excel.exe d:\dts_end.xls", 0, TRUE)

Main = DTSTaskExecResult_Success
End Function

I want to run an excel application in hidden mode

This excel file contains a macro that will send a DDEPOKE to an application supervisor (Monitor Pro).

As I hav'nt find how to modify a value in my supervisor with DDE in a DTS Package, I try by this way.

When i lauch my vbscript the error is :
"ActiveX Scripting encountered a Run TIme Error during the execution of the script"

Thanks

Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2006-10-04 : 09:37:13
Are you sure that the user running this script has operating system permissions?

As I can see this is a pure operating system command...I'd suggest you select Execute Process Task instead and see what happens. I don't see the need for any VBScripting here.

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

lawash44
Starting Member

5 Posts

Posted - 2006-10-04 : 09:45:29
Thanks
I'm sure that the user running this script has operating system permissions

There is no problem if I use Execute Process Task. I joust see Excel a few seconds(In my excel application i begin with Application.Visible = False)

I need to hide the Excel execution. Do you know how can I hide it totally with Execute Process Task ?

Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2006-10-04 : 09:55:32
I don't think this is possible but I don't know for sure...it happens for all other applications aswell. I have a few automated ftp scripts that do the same thing...but they usually run on a server so noone sees them pop up.

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

lawash44
Starting Member

5 Posts

Posted - 2006-10-05 : 03:55:03
Thank you for your response. But I need to hide execution.
Somebody else has an idea ?

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-10-05 : 04:21:14
There is one simple thing you can do:

Instead of giving long names in the path, try short names, like this:

objShell.Run("c:\progra~1\micros~2\office11\Excel.exe", 1, TRUE)


This may solve your problem. To find short names of directory, type this command at command prompt:

Dir /x


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

lawash44
Starting Member

5 Posts

Posted - 2006-10-05 : 04:59:05
Thank you very much Harsh
You solve my problem !

Fabrice
France
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2006-10-05 : 06:46:23
Wow not bad! And I thought that short file/foldernames were a thing of the past...I will definetly put "dir /x" in my bag of tricks!

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-05 : 07:08:54
Or just put double quotes around the program path, in case program files is not progra~1.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-10-05 : 07:31:27
quote:
Originally posted by Peso

Or just put double quotes around the program path, in case program files is not progra~1.


Peter Larsson
Helsingborg, Sweden



Peter,
How could you possibly put double quotes around path in DTS task?

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page
   

- Advertisement -