Welcome to the new CogKnowHow.com!


If you have trouble logging in, reset your password via the login window
by clicking the 'Forgot Password' link.

Run VBS Script from Macro


#1

Does anyone know how I can run a vbs script from a macro. I have been cobbling one toghether but cannot get it to work.

Sub Main()
Dim objShell as Object
Set objShell = _
CreateObject(“WScript.Shell”)
objShell.Exec (“cscript \amhs-ediis1\Ad Hoc Reports\Frank\ED Scheduled Reports\SendmailEDISv2.vbs”)
End Sub

Thanks


#2

Hi Frank,

i believe UNC path is not working well, the script looks fine to me.

did you try a ‘real’ path?

CreateObject("WScript.Shell") objShell.Exec ("cscript c:\SendmailEDISv2.vbs")


#3

Thanks for the reply. Yes, I did try with a mapped drive and still the same.

I am running the macro from the Cognos Scheduler ‘Script file name:’ option in the Results tab. While monitoring the scheduler, I can see a dos window open and shut so I believe Cognos is firing the script. When I run the VBS script manually, it works.


#4

I don’t have series 7 here to test my theory, but I thought I remember that to run through Cognos scripting it mattered what directory the executable resides in. Can you put the macro in the same directory as the reports, or is it already?


#5

oops should have proof read 2 times… I meant to say ‘to run through Cognos Scheduler, it mattered what directory the script executable resides in’.