VB脚本错误路径找不到路径(800A004C)

发布于 2024-11-02 05:14:27 字数 1311 浏览 1 评论 0原文

我需要创建 vbscript,它将创建新文件夹“test”和子文件夹“Output”。已经有一个文件夹结构 C:\Documents and Settings\All Users\Application Data\Fmwire,我需要在这些结构下创建 test\Output

我已经创建了这样的 vbscript,但我收到这样的错误

:错误:找不到路径 代码:800A004C 来源:Microsoft VBScript 运行时错误

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

                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

我必须做哪些更改才能纠正此错误

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

                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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瑕疵 2024-11-09 05:14:28
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
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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文