开发者

VB script error path Path not found(800A004C)

I need to create vbscript which will create new folder 'test' and subfolder 'Output'.There is already a folder structure C:\Documents and Settings\All Users\Application Data\Fmwire,I need to create test\Output under those structure

I have created vbscript like this but i am getting error like this

Error: Path not found Code: 800A004C Source: Microsoft VBScript runtime error

Const OSCPATH = "\Fmwire\test\Output"
Const ALL_USERS_APPLICATION_DATA = &H23&

Dim fso                 ' File System Object
Dim objApplication      ' Application object
Dim objFolder           ' Folder object
Dim objFolderItem       ' FolderItem object
Dim fname               ' Path to Settings folder 






                Set objApplication  = CreateObject("Shell.Application")
                Set objFolder = objApplication.Namespace(ALL_USERS_APPLICATION_DATA)
                Set objFolderItem = objFolder.Self
                fname = objFolderItem.Path & OSCPATH

       开发者_Python百科         Set fso = CreateObject("Scripting.FileSystemObject")
                If fso.FolderExists(fname) Then
                Set objFolder = fso.GetFolder(fname)
                Else
                Set objFolder = fso.CreateFolder(fname)
                   If Err Then
                     Err.Clear
                      strErr = SPOFOLDERFAIL
                      rCode = 4
                   End If
                End If

What changes i have to do for correcting this


Const OSCPATH = "\Fmwire\test\Output"
Const ALL_USERS_APPLICATION_DATA = &H23&

Set objApplication  = CreateObject("Shell.Application")
Set objFolder = objApplication.Namespace(ALL_USERS_APPLICATION_DATA)
Set objFolderItem = objFolder.Self
fname = objFolderItem.Path

Set fso = CreateObject("Scripting.FileSystemObject")
folders = Split(OSCPATH, "\")
For i = 0 To UBound(folders)
    fname = fso.BuildPath(fname, folders(i))
    If fso.FolderExists(fname) Then
        Set objFolder = fso.GetFolder(fname)
    Else
        Set objFolder = fso.CreateFolder(fname)
       If Err Then
         Err.Clear
          strErr = SPOFOLDERFAIL
          rCode = 4
       End If
    End If
Next
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜