Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2006
    Posts
    5

    Red face Unanswered: 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.

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    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? ***

  3. #3
    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






  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    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? ***

  5. #5
    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 21:05.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •