If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Executing Visual Basic ActiveX Script by scheduled task

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-30-10, 17:53
rsbutterfly16 rsbutterfly16 is offline
Registered User
 
Join Date: Jul 2006
Posts: 5
Red face Executing Visual Basic ActiveX Script by scheduled task

hi i have created an which is running perfectly under a ssis package with the desired output , but i tried executing it as a windows scheduled task and eventhough it runs with no errors it does not do anything.

'************************************************* ***********
' Visual Basic ActiveX Script
'************************************************* ***********
Function Main()
sFile = "C:\Logs\dts.log"

Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists(sFile) Then
oFSO.DeleteFile sFile, TRUE
End If
Main = DTSTaskExecResult_Success
End Function

I do have all the permissions to do this delete

this is what i did.

I have the script saved as a c:\temp\scripts\rename.vbs

i went to schedule tasks, under run i clicked browse and choose my vbs file, added my login. It runs fine but like i said it does not return any outputs.


Can someone tell me what am i doing wrong.
Reply With Quote
  #2 (permalink)  
Old 05-03-10, 09:35
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
DTSTaskExecResult_Success means nothing to windows scheduler. If you're running this thing from the command line by way of windows scheduled task, it's probably returning the contents of an empty variable called DTSTaskExecResult_Success. If you run it from inside a sql server package as an actual ActiveX script (not just a command line call), then that variable has a special meaning. If not, then it's just another plain old variable. You may as well say "Main = YayILikeToNameVariables". It would have the same effect.


What is it you're trying to do, exactly?
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
  #3 (permalink)  
Old 05-03-10, 16:43
rsbutterfly16 rsbutterfly16 is offline
Registered User
 
Join Date: Jul 2006
Posts: 5
hi thanks for your reply i am trying to run and execute the following active x script through a scheduled task. I changed the code a little bit, i want to just add the current date in some files. Like i said when i execute this through a ssis package it adds the date to the files but when i run it by schedule tasks eventhough i get no errors no dates are added.


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

Function Main()

Dt = now()

y = Right(Year(Dt),2)
m = Month(Dt)
d = Day(Dt)

If Len(m) = 1 Then
m = "0" & m
End If

If Len(d) = 1 Then
d = "0" & d
End If

Filename= m & d & y & ".txt"


SFile ="C:\archive\"

DFile ="C:\archive\"


SFile1 = SFile &"UtilityDB_log_"& Filename
SFile2 = SFile &"Distributor_log_"& Filename



DFile1 =DFile & "UtilityDB_log.txt"
DFile2 =DFile & "Distributor_log.txt"



Set FSO = CreateObject("Scripting.FileSystemObject")



If (FSO.FileExists(DFile1)) Then


Set NewFile = FSO.GetFile(DFile1)
NewFile.Copy(SFile1)
FSO.DeleteFile(DFile1)


End If

If (FSO.FileExists(DFile2)) Then

Set NewFile = FSO.GetFile(DFile2)
NewFile.Copy (SFile2)
FSO.DeleteFile(DFile2)

End If




Set FSO = Nothing
Main = DTSTaskExecResult_Success
End Function





Reply With Quote
  #4 (permalink)  
Old 05-03-10, 16:55
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
I think you were right to be sniffing around credentials...

What identity did you specify your scheduled task to run under?

If you were in SSIS and ran the package manually, it would have run as you. If you ran it as a scheduled SSIS job, then it would run as the default identity for sql agent (unless you specified something different). Windows scheduled tasks can run as any identity. It could very well be that while YOU have NTFS permissions to the location of interest, the identity that windows scheduler is running under does not.

Try a simple test. Create a script that will do nothing but create a test file. Nothing more. See if you can get that to work.
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
  #5 (permalink)  
Old 05-03-10, 18:13
rsbutterfly16 rsbutterfly16 is offline
Registered User
 
Join Date: Jul 2006
Posts: 5
i added my credentials to the scheduled task and run the package with my id.
i did create a simple script to create a txt file, same thing it did by visual studio/ssis package but by scheduled task run ok but no creation of file.

Can you tell me the steps to make this active x scripts run from scheduled task? maybe i am missing something there

Last edited by rsbutterfly16; 05-03-10 at 20:05.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On