VB script and UNC paths

  • I have this step in SQL Server 2000 SP4 on Windows 2003 Advanced server

    Here is the code and it's very simple..I want to delete files from one folder and then copy another folders contents into this folder. It works fine as long as it's on the same server as SQL but when I use a UNC path I recieve errors.

    Dim objFSO

    Dim fld 

    Dim fl 

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set fld = objFSO.GetFolder("\\myserver\wwwroot\MyInteranet\MyFolder\archiveRates\PDF2\")

        For Each fl In fld.Files       

                fl.Delete        

        Next

    set objFSO  = nothing

    set fld   = nothing

    set fl   = nothing

     

    when I run this job I receive the following error:

     

    Executed as user: MyCompany\SQLServer. Error Code: 0  Error Source= Microsoft VBScript runtime error  Error Description: Path not found    Error on Line 6.  The step failed.

     

    what is the deal with vbs and jobs with UNC paths?

  • Has your MyCompany\SQLServer user been granted full control over the target folder?  Has the target folder been set up as a share? 

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Yes, I have done full permissions on both folders.

  • I would suggest verifying the permissions by performing a manual copy using you SQL user.  Log into your SQL box as the user in question, go to start>>run and type in the UNC path to the folder you are deleting from.  Perform you delete operations.  Open up another Windows explorer session using start>>run>>UNC and do your copy or move.  I know that you checked permissions, but you need to make sure the folders are shares.  Check the share permissions.  From you UNC path that you are showing in your example, it looks like you may be using an internet share (IIS).  Is this correct?  If so, you do not need to use the full path as IIS will not recognize the share if you do.  For example, if your web-share is set up on your PDF2 folder, the UNC path to that folder would be \\myserver\PDF2.  Make sense?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply